Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Whenever I try generating an excel report, the log file created in my computer's APPDATA folder shows the following error :
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error009480_01.xml</logFileName><summary>Errors were detected in file 'E:\fb\report\resources\g_Report.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>

How can I avoid this ?
Posted
Updated 8-Jan-14 19:45pm
v2

This generally means there is some sort of corruption in the Excel file. Maybe, if you show the code you are using to generate the file, someone can suggest where the corruption is occurring.
 
Share this answer
 
Comments
siddharth629 9-Jan-14 2:28am    
sir,
this error is occured when i m generating the file wit .xlsx file but
when i m generating .xls file with same code then there is no warning or msgs same code
Wayne Gaylard 9-Jan-14 2:37am    
This would suggest you are using some code that is incompatible with newer versions of Excel
siddharth629 9-Jan-14 3:06am    
this is the code for WORK BOOK..........

public static Workbook GetWorkbook(String _fileName)
{
var excel = new Application();
var workbook = excel.Workbooks.Open(_fileName, 1, true,
5, "",
"", true,
XlPlatform.xlWindows, "",
true, false,
0, false,
false, true);
excel.Visible = false;
return workbook;
}

........this where i m writng data


public byte[] GetRiskReportByte(IList riskList, RiskListHelper risklisthelper)
{
string fileName = null;
Workbook theWorkbook = null;
fileName = "_Report.xlsx";
theWorkbook =GetWorkbook(AppDomain.CurrentDomain.BaseDirectory + "\\" + "Report" + "\\" + "_Report.xlsx");
var worksheet = (Worksheet)theWorkbook.Sheets[1];
var worksheet2 = (Worksheet)theWorkbook.Sheets[2];
worksheet.Name = "xyzReport";
worksheet2.Name = "zzz";
worksheet.Cells[1, 1] = "Risk Name";

worksheet.Protect("abc@123$", false, true, false, true, false, false, false, false, false, false, false, false, false, false, false);
worksheet.Cells.Locked = false;

theWorkbook.SaveCopyAs(fileName);
byte[] byteContent = ExportImportUtil.StreamFile(fileName);
File.Delete(fileName);

theWorkbook.Close(false, fileName, true);
return byteContent;
}
Make sure you have the following at the end of your "response" logic:


Response.Flush();
Response.End();
 
Share this answer
 
Comments
manish_rcc 14-Jun-18 5:30am    
Thanks.. This code is working for me.

Response.Flush();
Response.End();

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