Skip to content
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

Investigate "Unreadable content" Issue #38

Closed
AmirBosch opened this issue Sep 19, 2016 · 5 comments
Closed

Investigate "Unreadable content" Issue #38

AmirBosch opened this issue Sep 19, 2016 · 5 comments

Comments

@AmirBosch
Copy link
Contributor

https://closedxml.codeplex.com/workitem/8466

@AmirBosch AmirBosch changed the title Investigate Unreadable content" Issue Investigate "Unreadable content" Issue Sep 19, 2016
@Its-Just-Me
Copy link

Its-Just-Me commented Sep 20, 2016

If it helps, I got around this using the following code;

Private Sub FixWorkBook(ByVal ms As MemoryStream)
    Try
        Dim owb As SpreadsheetDocument = SpreadsheetDocument.Open(ms, True)

        For Each element In owb.WorkbookPart.Workbook.ChildElements
            If element.LocalName = "extLst" Then element.Remove()
        Next

        For Each element In owb.WorkbookPart.WorkbookStylesPart.Stylesheet.ChildElements
            If element.LocalName = "extLst" Then element.Remove()
        Next

        owb.Close()

    Catch ex As Exception
        LogError(ex, "FixWorkBook")
    End Try
End Sub

@igitur
Copy link
Member

igitur commented Sep 21, 2016

I don't think blindly removing workbook parts is a good fix. There might be instances where a user really wants those parts. Let's rather try figure out the underlying issue.

Am I correct in saying that the problem is that ClosedXML generates files that open correctly on both Excel 2010 and Excel 2013 the first time. But when the files are then saved in Excel and reopened, Excel 2010 is unable to do so, but Excel 2013 can do that? I read the original thread on Codeplex, but I'm unable to see a consistent reproduction of the error. People over there are mentioning all kinds of manifestations. If we can get a unambiguous set of steps to reproduce the problem, we can fix it. In the meantime, I'm hunting down a copy of Office 2010.

@Its-Just-Me
Copy link

Sorry, try as I might, I'm unable to reproduce it now, using either 2010 or 2013. I even rolled the ClosedXML version back to 72.3, which I was using back then (it was in 2014). It was consistent however, hence the code to work around.

The details of the error were;
Removed Part: /xl/styles.xml part with XML error. (Styles) Undeclared prefix. Line 2, column 8718.
Repaired Records: Cell information from /xl/worksheets/sheet1.xml part
Repaired Records: Column information from /xl/worksheets/sheet1.xml part

From memory, the issue was that the styles.xml file referenced the extension x14 at the start and defined it at the end; ie

<x:styleSheet xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" ...

<x:extLst><x:ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}">

But when saved in 2010, the reference at the start would be dropped and excel would have problems opening it. I found that deleting all the extLst elements solved the problem and didn't cause any issues. I assume excel recreated them where required.

Being that I can't recreate it, perhaps an Office update managed to fix the issue...?

@AmirBosch
Copy link
Contributor Author

OK we will close this for now :)

@igitur
Copy link
Member

igitur commented Sep 23, 2016

Yeah, one guy said applying KB2889836 solves this issue in Excel 2010. Maybe that really was the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants