Comments (5)
Hi @nmg196,
an xlsx file is just a zipped library of xml-files - to view the internal files of any *.xlsx file you can just rename the file from *.xlsx to *zip and open it.
The reason for the "Data at the root level is invalid" error is that the xml files inside this particular xlsx-file are encoded with UNICODE whereas EPPlus uses UTF-8 when reading them.
Since EPPlus assumes that the xml-files are encoded in UTF-8 the result of the file becomes like this:
��<\0?\0x\0m\0l\0 \0v\0e\0r\0s\0i\0o\0n\0=\0\"\01\0.\00\0\"\0?\0>\0\r\0\n\0 \0<\0T\0y\0p\0e\0s\0 \0x\0m\0l\0n\0s\0=\0\"\0h\0t\0t\0p\0:\0/\0/\0s\0c\0h\0e\0m\0a\0s\0.\0o\0p\0e\0n\0x\0m\0l\0f\0o\0r\0m\0a\0t\0s\0.\0o\0r\0g\0/\0p\0a\0c\0k\0a\0g\0e\0...
...and the "Data at the root level..." exception is thrown when EPPlus tries to load the xml-string into an XmlDocument.
The reason that it works when you have resaved the file with Excel is most likely converts the files to UTF-8.
I don't think that we have had this reported before, but we will have a look at it and see if we can handle this internally in EPPlus and provide a fix in a coming version.
With the current version EPPlus will unfortunately not be able to read these files.
from epplus.
@nmg196 - May I ask how your xlsx-files were created? By Excel or another tool? If Excel, do you know which version of it?
from epplus.
The files are output by a widely used trading platform called MetaTrader 5 (https://www.metatrader5.com/). If this is an edge case, then perhaps I can extract and repack the files if I detect this error. However that said, Excel is able to open them OK which indicates this is a supported file encoding for XML/xlsx files.
from epplus.
I did some testing and we can add support for this in EPPlus by checking the BOM of the files and then process the internal files according to the format. I will add this as a feature to implement in one of the coming versions.
from epplus.
That would be great :)
from epplus.
Related Issues (20)
- Rich Text fails with v7.1.0 - renders as "OfficeOpenXml.Style.ExcelRichTextCollection" HOT 2
- ws.Drawings.AddPicture don't support jpeg/exif HOT 4
- Add support for rotation on shapes and pictures HOT 1
- Apostrophe's in dateformat's were not escaped HOT 1
- Delete blank rows HOT 1
- Update to 7.1 ExcelRange.LoadFromCollection error: The Order property has not been set. Use the GetOrder method to get the value. HOT 2
- Invalid defined names are failing to get copied. HOT 1
- Patternfill issue
- Cell/value meta data is not copied when copying a range between workbooks
- Bar chart (ColumnClustered) Data Labels Rotation HOT 3
- Values from the names manager are expanded with additional quotation marks HOT 1
- Support for the GetPivotData function - PivotTable Calculations
- Add support for newer Excel functions
- Richtext and inline-strings
- Issue with Negation of Defined Named and Ranges in Formula Calculation HOT 1
- Nullable Type member column is not shown in LoadFromCollection() with Members using version above 7.0.10.0. HOT 1
- Automap exception workflow issues HOT 4
- Copy ExcelGroupShape to another sheet HOT 1
- "Can't set bordercolor when style is not set." on Runtime Cell Creation HOT 2
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 epplus.