I am using Aspose.Cells for .net to generate html, excel and PDF reports.
I was able to generate html and excel reports without any problem. But, when I tried to generate the PDF report, I received the error as “File is damaged and could not be repaired.”
I created a method which returns the stream data and then I am viewing the data (report) on a different page using HttpResponse object.
public System.IO.Stream GetReport(string type)
{
System.IO.Stream s = new System.IO.MemoryStream();
InitializeAspose();
Workbook b = new Workbook();
Worksheet ws = b.Worksheets[0];
SetWorksheetColumnWidth(ws);
SetHeader(ws);
PushData(b, ws);
SetFooter(ws);
if (type.ToLower() == "excel")
b.Save(s, FileFormatType.Default);
else if (type.ToLower() == "pdf")
{
b.Save(s, FileFormatType.Pdf); //not working.
//b.Save(@"c:\\test.pdf", FileFormatType.Pdf); //this one is working fine. But I want the above method to work.
}
else if (type.ToLower() == "html")
b.Save(s, FileFormatType.Html);
s.Position = 0;
return s;
}
Thank You for your help!
Usha
This message was posted using Email2Forum by Laurence.
I tried the latest version of Aspose.Cells 4.7.0.2 and i am still getting the same error. I am using Adobe Reader 9 version 9.0.0. to view the report. What version of Adobe Reader it supports?