Coder Social home page Coder Social logo

Comments (9)

dten avatar dten commented on July 18, 2024 1

I'd be happy to

from xlsx.

qrilka avatar qrilka commented on July 18, 2024

Thanks for raising this. What Excel versions result in that error? Does the example https://github.com/qrilka/xlsx/blob/master/src/Codec/Xlsx.hs#L22-L36 give you that error as well? Your words sound like you have an idea how to create a PR with a fix - do you want to open one?

As for me unfortunately I don't have a desktop version of Excel and I'm not sure how good enough is testing with the online version...

from xlsx.

dten avatar dten commented on July 18, 2024

I'm just using Excel 2013.

the example you list won't give the error because it doesn't serialise the def of StyleSheet. Instead it jumps straight to the bytes emptyStyles gives https://hackage.haskell.org/package/xlsx-0.8.2/docs/src/Codec.Xlsx.Types.html#emptyStyles

which formatted looks like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
</styleSheet>

but serialising def of styles results in

<?xml version="1.0" encoding="UTF-8"?>
<!--Stylesheet generated by xlsx-->
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
	<numFmts count="0"/>
	<fonts count="0"/>
	<fills count="0"/>
	<borders count="0"/>
	<cellXfs count="0"/>
	<dxfs count="0"/>
</styleSheet>

which results in excel complaining unless I either remove the dxfs element or provide the default fonts like minimalStylesheet does.

Not writing out the empty elements would result in an excel file that loads. However you soon run into the cases where Excel expects something non trivial specified so it's only a small help. I was thinking the docs could be more helpful but they're already pointing out the problems... maybe just needs some bold 😅

from xlsx.

qrilka avatar qrilka commented on July 18, 2024

I need to take a look if there's anything in the spec about this or if it's another "feature" of the implementation. But if you have any concrete ways to improve the situation - PRs are welcome for sure.

from xlsx.

qrilka avatar qrilka commented on July 18, 2024

@dten I had a look into the spec and I don't see anything there telling that the style above shouldn't be accepted. But I guess it still makes sense to take this implementation detail into account. The only idea I have right now is just removing the Default instance for StyleSheet altogether and publish it as something like emptyStylesheet with a huge warning saying that Excel won't accept it as it is the details of that are rather unknown and minimalStylesheet should be preferred. And as this looks like a breaking change that would require a major version update.
Do you see any other ways to resolve this?

from xlsx.

dten avatar dten commented on July 18, 2024

So I think not writing out the empty elements would help. That would basically mean the special case from emptyStylesheet wasn't special

from xlsx.

qrilka avatar qrilka commented on July 18, 2024

Sorry, do you mean that we just need to make countedElementList in https://github.com/qrilka/xlsx/blob/master/src/Codec/Xlsx/Types/StyleSheet.hs#L1145-L1152 skip produce no element if a list has zero elements? That looks doable and backwards-compatible as well.
But what about "the cases where Excel expects something non trivial specified so it's only a small help"? Do you think that mentioning something along those lines in haddocks would be a good enough solution?

from xlsx.

dten avatar dten commented on July 18, 2024

Yes I mean skip the counted list if it's empty

As for non trivial case, I mean in the case where people start adding some elements to styles. The link in the docs explains that there is a point where Excel won't open the file because it only part of the stylesheet is specified.

http://hackage.haskell.org/package/xlsx-0.8.2/docs/Codec-Xlsx-Types-StyleSheet.html#v:minimalStyleSheet

from xlsx.

qrilka avatar qrilka commented on July 18, 2024

Thanks. Yes the link explains some details but I think it's not prominent enough so it's easy to miss that part. I'll try to make it more explicit (e.g. mention that Excel has some not quite clear requirements about stylesheet contents). Would you mind me assigning you as a reviewer for a PR about this?

from xlsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.