Getting Excel Found unreadable content in .xlsm file using open xml SDK 2.0 RRS feed

  • Question

  • Hi,

    We are getting error like "Excel found unreadable content in 'file.xlsm'.  Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes"

    We are using template containing macro (.xltm) to generate excel (.xlsm). Using openXML SDK code for updating values in excel cell. Having large code for putting values in cell as it is involved all business logic. After updating we are saving that file as file.xlsm.

    Please advise why getting such error.


    Monday, October 22, 2012 9:54 AM

All replies

  • Hi Gitu10,

    Thanks for posting in the MSDN Forum.

    It’s based on my experience that we are hard to say anything until you provide me some key code for further trouble shooting. I would recommend you do that if it is possible. If you have trouble to show it. I would recommend you use Open Xml SDK 2.0 Productivity Tool to open your destination document to see whether there have unknown node in your SpreadsheetDocument. It can find some of the problem however it isn’t all. As far as I know the order of the specific node is request. So create a simple project to reproduce your issue and show me your code is make more sense.

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 23, 2012 1:53 AM
  • Gitu,

    Do you still need assistance on this question? Can you share the document that can reproduce the problem? I want to analyze it. is ideal for sharing. For security concern, you can share with my Windows account forrest_msdn@hotmail.

    The error generally indicates the document has invalid content, see this article:

    Forrest Guo | MSDN Community Support | Feedback to manager

    Thursday, October 25, 2012 3:12 PM
  • Please find my sample code below. Where test.xltm contains 1 Activex command button only.

    Dim strTemplatePathName As String

    strTemplatePathName = "D:\work\test.xltm"

    Dim MyOpenXML As SpreadsheetDocument = Nothing

    Dim ms As MemoryStream

    ms = GetStreamData(strTemplatePathName)

    document = SpreadsheetDocument.Open(ms, True)


    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetxml.sheet"

    Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", "test.xlsm"))

    Response.Charset = ""




    Saturday, October 27, 2012 4:51 AM
  • I'm not familiar with server side scripting. Where should above script snippet reside?  I tried aspx <% code snippet%> but the OpenXml class doesn't get resolved.

    Forrest Guo | MSDN Community Support | Feedback to manager

    Saturday, October 27, 2012 1:33 PM