-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
SXSSFWorkbook generated xlsx file cannot be import by PowerBI #1443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you upload the generated xlsx file? And How do you import this xlsx into PowerBI? Please let me know the reproduction steps. |
Here is some basic example code and the generated spreadsheet (it affects all spreadsheets)
The stray UTF8 BOM character is within the xl\worksheets\sheet1.xml file just after the opening As for importing into PowerBI, this is a process that our customers do with the generated spreadsheets and is not something we do ourselves; it has now been reported by multiple customers, each customer with their own use cases and processes. We were previously using the non-streaming XSSF functions to generate the files, and these were generated without issue, it is only since switching to the streaming SXSSF functions that the issue has started. |
Hi. This problem is not specific to PowerBI, it is creating a malformed document, it's just that Excel must work around it when opening the files. It seems to be a simple case of needing to remove this override to the encoding in the SheetDataWriter: The vast majority of StreamWriters in the solution don't use the override, and rely on the the default encoding, which is UTF8NoBOM: |
@tonyqus can you please make the simple change proposed by @scousesheriff and @msmith-work? The extra BOM also causes the same XmlNodeType error referenced in this issue when a user queries a document with Excel PowerQuery. My kludge is to use reflection to set the It does not seem like PRs are being reviewed, but I'll create one if you think it would help. |
NPOI Version
Current
File Type
Reproduce Steps
Using streaming SXSSFWorkbook, generate a simple spreadsheet output
Issue Description
The generated xlsx file contains a stray UTF8 BOM (ZWNBSP) character in xl\worksheets\sheet1.xml between
<sheetData><row r="1">
.The file can be opened without issue in Excel, however importing this file into PowerBI results in the error message "'Text' is an invalid XmlNodeType, Line 1, position x"
On investigation, it appears the temp file created for streaming is done so using a UTF8 encoding (SheetDataWriter.cs constructor), this then forces the temp file to contain the UTF8 BOM character, which then appears to be inserted into the final spreadsheet just after the opening
<sheetData>
tagThe text was updated successfully, but these errors were encountered: