Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Saving Workbook in Excel 2007 Format produces Document
posted

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

Parents
  • 44743
    posted

    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:

    1. Take your exported .xlsx file and rename it so the extension is .zip (you may have to change your windows explorer settings so file extensions are not hidden for known file types).
    2. Unzip the file.
    3. Open the file at /xl/worksheets/sheet1.xml in the extracted folder.
    4. Copy line 11 and paste it in your reply (my guess is it will be the <sheetFormatPr> element).

    Thanks for your help.

Reply Children