Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hi Experts,

please help me
Here is my sample code

// open Excel file:
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Worksheet xlSecWorkSheet;
object missing = System.Reflection.Missing.Value;
// FileName [with full path]
xlWorkBook = xlApp.Workbooks.Open(FileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

//add some list values in each cell of the particular column, using the following code
StringBuilder sbvalue = new StringBuilder();
for (int i = 0; i <= 10; i++)
{
sbvalue.Append(i.ToString());
}
// add the list in a excel cell [entire column]
validationRange.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlBetween,
sbvalue.ToString(), "");
and finally save the file

xlWorkBook.SaveAs(FileName, Excel.XlFileFormat.xlExcel12, missing, missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);

The problem here is, the finally saved excel file could not open in Office 2010 and the list values where removed

the error is:
Excel found unreadable content in <filename>. Do you want to recover
the contents of this workbook. If you trust the source of this workbook click Yes.

while click on yes continuously, found that in the Excel sheet, the list is missing

Please help in solving this issue.

Thanks in advance
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900