I can not create an Excel 2007 file(xlsx) that will open without excel telling me that there is unreadable content in the workbook and that it needs to be repaired.
If I say yes to repair, the file is opened with another dialog with the message
Removed Records: Cell information from /xl/worksheets/sheet1.xml part
The contents from the log file are as follows
Hi,
With this log it is difficult to tell what is wrong in the cell. Use Open XML SDK 2.0 Productivity Tool for Microsoft Office and do a validation of this file.
Thanks Pramod. I installed the tool and validated the file. It is pointing to the error in styles.xml. The error is about the font. The element has expected child element
http://schemas.openxmlformats.org/spreadsheetml/2006/main:sz .
I guess this has to do with the sz element not coming first under x:font. It should be x:font and under that x:sz element.
and in my case it is x:font , then x:name and then x:sz. But I am not sure why this is happening. Please help me understand this. I am trying to make sense as to how this styles.xml is getting populated like this.
If you can share the code and the erroneous excel file that would help to solve the problem.
Thanks
Looks like you are missing the "xmlns" attribute from the styleSheet element, as follows:
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
I will see if I can separate out a code that can be run independently for you to have a look. In the current format I can't share the code due to company policies. But the strange thing I am observing is , even though I comment out the styleindex parameter from the createCell method and thereby creating the sheet without any styles, I still get the errors regarding the fonts. I would have assumed that without any styles, it should not give the error.
HI Bobm,
I had a look at my styles.xml and I can see the namespace element in there.
I am not sure how the styles.xml gets generated in the Excel generation process. If I can have a control over that then I can may be change the order of the elements in the font and may be solve this process. If you know how the styles.xml gets generated, how it is populated then you can help me understand the process.
Hi Pramod,
After removing all the fonts from my code, I could generate the xlsx file which had no validation errors when validated in productivity tool. So that's good. But still the Excel is complaining about the unreadable content and it opens the file only after repairing. How should I move ahead. I thought that once we get no validation errors in the productivity tool, then excel opens the file without any errors. But I suppose I am wrong.
Check whether you created the WorkSheet like below or not.
Worksheet worksheet = new Worksheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } };
worksheet.AddNamespaceDeclaration("r", "schemas.openxmlformats.org/.../relationships");
worksheet.AddNamespaceDeclaration("mc", "schemas.openxmlformats.org/.../2006");
worksheet.AddNamespaceDeclaration("x14ac", "schemas.microsoft.com/.../ac");
Not that even if you not add/provide these attributes [(Ignorable = "x14ac") & (worksheet.AddNamespaceDeclaration("mc", "schemas.openxmlformats.org/.../2006")) ]
The Productivity Tool does not give error and if you try to open the file using Excel, that gives and error message saying 'Cell information is incorrect' & style1.xml part has been removed from the Workbook.
If you can share the excel generated, it is easy to rectify the problem.
I will check about the namespaces. In the meanwhile, please find the excel attached.
I'm in a great trouble with a data sheet of Excel 2003. I can't open it via Excel 2007 or 2010. But those data is so much important for me. Can you help me to open it ?
Regards,
Carmest
Send me the file. I will try to see what's wrong with it.