Comments (9)
I'd be happy to
from xlsx.
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.
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.
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.
@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.
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.
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.
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.
from xlsx.
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)
- Add search ability to Hackage page HOT 3
- Depend on microlens instead of lens? HOT 3
- NonEmpty list of worksheets HOT 3
- How to insert a row HOT 4
- Add writing support for large excell files (streaming?) HOT 10
- microlens flag still builds lens as a dependency
- Hyperlink Support HOT 7
- Leaking merge information across worksheets HOT 1
- Handling dates before 1900-03-01 HOT 3
- Add newtype for column and row indexes
- Add integration test that checks correctness with xlsx validator
- Support lens v5.1 HOT 5
- Hackage docs are broken HOT 9
- We shouldn't be able to make sheetnames bigger then 31 characters. HOT 1
- Cell Range dataValidation problem HOT 5
- Still applying code formatting? HOT 4
- Proper support for cross-sheet references, was "Errors creating pivot tables in separate sheets" HOT 4
- Test files missing in sdist HOT 4
- Request: Minimal working example for styles HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlsx.