Hi
I have an excel file that I want to modify. This file contains a table.
I want to delete all the table data rows except the last one (leave the colum headers and one data row).
With the remaining data row , I want to clear the content (only the content not the formating) of all the cells that are not formula cells.
I want all the formula cells to remain as they are.
when doing this , after I try and opening the saved file , excel gives an error message that data is corrupt - Attached are the original and saved files. Below is the code that does it.
{
w.Cells.DeleteRange(listObject.StartRow + 2, listObject.StartColumn, listObject.EndRow, listObject.EndColumn, ShiftType.Up);
}
//NOW clear content of last remaing data row except for the formula cells
foreach(Cell cell in w.Cells.Rows[listObject.StartRow + 1])
{
if(!cell.IsFormula)
{
cell.PutValue(null);
}
}
BTW - the same happens if I clear the content using
w.Cells.ClearContents(listObject.StartRow + 1, listObject.StartColumn, listObject.StartRow + 1, listObject.EndColumn - 1);
Please Help
Ryan