"Unable to read file" error when trying to Save


#1

I am trying to use Aspose Excel for the first time and I am having trouble getting it to work. I have a website that needs to generate an excel file and open it in a new window. I want it to work something like the following code would work:

Response.Clear();
Response.Buffer= true;
Response.ContentType = “application/vnd.ms-excel”;
Response.Write(“

Test
”);
Response.End();

Here is how I have tried to do this with Aspose:

Excel ExcelDocument = new Excel();
Cell cell1 = ExcelDocument.Worksheets[0].Cells[“A1”];
cell1.PutValue(“test”);
ExcelDocument.Save(“test.xls”, Aspose.Excel.SaveType.OpenInExcel, Aspose.Excel.FileFormatType.Default, Response);

When this opens Excel it gives me the error message “Unable to read file” and opens a blank worksheet. Could you please tell me what I am doing wrong.
Thanks



#2


Please remove your code:
Response.Clear();
Response.Buffer= true;
Response.ContentType = “application/vnd.ms-excel”;
Response.Write(“

Test
”);
Response.End();


Do you want to open the generated file in a new IE window or a new Excel window?

If you want to open it in a new Excel window, removing your code will be fine.

If you want to open it in a new IE window, please put some java script code in you web page. Those code will create a new IE window and direct to a new web page. In this web page, you can generate the result file.