hi, we have been experiencing a problem with certain excel template files. for the attached example, the original template has a used range which ends at column P, after removing the first column programmatically and opening the resulting file with excel 2007 or 2010 it appears to have a used range that extends to column XFC. it appears that copy and pasting all cells on the template from the problematic sheet to a new sheet and saving it with the same name fixes the problem, but this issue has shown up on many of our templates and sometimes reoccurs after it has been copy/pasted/saved. the .Cells.MaxColumn and .Cells.MaxDataColumn seem to show the correct values, is there any other way to set excel’s UsedRange? can you tell what specifically about the sheet causes the issue?
Hi,
Workbook currentWorkbook = new Workbook(“e:\test2\problem_template.xlsx”);
currentWorkbook.Worksheets[0].Cells.DeleteColumn(0);
currentWorkbook.Save(“e:\test2\outnew.xlsx”);
the output you included shows the problem when i open it with excel 2010 on my windows 7 x64 machine. the position marker on the horizontal scroll bar displays very small and when you push Ctrl+End (go to the last cell in excel’s UsedRange) it goes to cell XFC4. if you run the same code on the attached fixed_template.xlsx you should see the expected result (the horizontal scroll bar is the same size as it appears in the template and Ctrl+End goes to O3)
Hi,