Hi,
I developed export to excel file for one ASP.NET app. And i have following error:
The message received from server could not be parsed.
Code (in short):
byte[] file = new byte[500000];
...
using (SqlDataReader rr =
c.ExecuteReader(CommandBehavior.SingleRow))
{
rr.Read();
file = ((byte[])rr["EXPORT_EXCEL_TEMPLATE"]);
}
System.IO.FileStream fileStream = System.IO.File.Create(path);
fileStream.Write(file, 0, file.Length);
fileStream.Close();
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open(path);
IWorksheet sheet = workbook.Worksheets[0];
//FILLING EXCEL FILE
workbook.SaveAs("Soubor.xls", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
And after that i see the error messsage.
When i use:
workbook.SaveAs("D:\\File.xls");
Everythink is OK, file is right and can be opened by MS Excel.
But when i use:
Response.Write(workbook);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=PorovUkazatelu.xls;");
Response.Charset = "windows-1250";
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1250);
Message is showen again.
So file is OK, but canot be sended via Response. Can somebody help me?
error_8badde5e.zip