I am facing an issue when creating an excel sheet using Template.
I found an issue when Auto filter is applying this error comes on opening an excel file.
Microsoft Office Excel File Repair Log
Errors were detected in file 'C:\Documents and Settings\saharsh.shah\Desktop\Candidates_Jul-25-2011-180818.xls'
The following is a list of repairs:
Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted.
For that I had use this code:
FileStream fs = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
HSSFWorkbook oHSSFWorkbook = new HSSFWorkbook(fs);
HSSFSheet oSheet = (HSSFSheet)oHSSFWorkbook.GetSheet(dt.TableName);
oSheet.SetAutoFilter(new CellRangeAddress(m, m + dt.Rows.Count - 1, 0, dt.Columns.Count - 1));
where m stands for Last row number before adding data to sheet from data table, and dt stands for data table.
Please provide me solution as soon as possible.