My application allows exporting database tables to Excel. As I switched to new XLSX format I have noticed that Excel 2007 always requires a file repair before file can be opened.The problem occurs even with very simple data in the test code below:
WorkbooktestWorkbook = new Workbook();testWorkbook.SetCurrentFormat(WorkbookFormat.Excel2007);Worksheet worksheet = testWorkbook.Worksheets.Add("Test Sheet");worksheet.Rows[0].Cells[0].Value = "Test value";testWorkbook.Save(targetFilePath);
If I try to open generated file the first time with Excel 2007, it claims the format is invalid and makes a repair with following repair log summary. (Unfortunately I have a German version of Excel, so the summary text was in German. I have translated it myself, so it might be different from the English version. )
<repairedParts summary="Following repairing has been done:_x000d__x000a__x000d__x000a_"> <repairedPart>Repaired part: /xl/worksheets/sheet1.xml-Part with XML error. Error loading data. Line 11, Column 71.</repairedPart> </repairedParts>
By the way, the generated file can't be opened with Infragistics either:
testWorkbook = Workbook.Load(targetFilePath);
causes System.ArgumentOutOfRangeException is thrown at Infragistics.Excel.WorksheetCollection.get_Item(Int32 index)
If Excel97To2003 workbook format is used, correct xls file is generated and can be opened with Workbook.Load.
Am I doing something wrong or is it a known issue?If it is a known issue, is any hotfix planned? (December Hotfix for Infragistics 8.3 did not help)
Thanks in advance.
DFE
You were right, it is a culture problem.Changing thread culture to "en-US" has solved the problem.
Thanks
Here is line 11 from sheet1.xml
<sheetFormatPr defaultColWidth="9,140625" defaultRowHeight="12,75" />
I have not seen this issue and was not able to reproduce it. I think I know what the problem might be though. It looks like the xml data was written out with culture specific separators when it probably should have been written out with constant separators. If you can post the erroneous line from the xml, it would really help in determining what the problem is:
Thanks for your help.