Invalid file format error


#1

I'm trying to open the excel 2003 file with the version 3.1.1.0 and it gives this error message. Prompt response will be much appreciated.

Server Error in '/EReg' Application.

Invalid file format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Invalid file format.

Source Error:

Line 149:			
Line 150:			Excel ex = new Excel();
Line 151:			ex.Open(path,FileFormatType.Excel2003);
Line 152: 
Line 153:			Worksheet sh = ex.Worksheets["DataSheet"]; 			

Source File: c:\inetpub\wwwroot\ereg\webform1.aspx.cs Line: 151

Stack Trace:

[Exception: Invalid file format.]
   Aspose.Excel.ദ.ٽ(MemoryStream Ԏ) +1095
   Aspose.Excel.ദ.ٽ(String ߧ) +115
   Aspose.Excel.Excel.Open(String fileName, FileFormatType type) +552
   EReg.WebForm1.generateFile() in c:\inetpub\wwwroot\ereg\webform1.aspx.cs:151
   EReg.WebForm1.Excel_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\ereg\webform1.aspx.cs:138
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

the code is:

private void Excel_Click(object sender, System.EventArgs e)

{

Excel ex=generateFile();

ex.Save(@"C:\shailendra\AlbertaCalc\Copy of Alberta HRCL Refi APR Calculator.xls",FileFormatType.Excel2003 );

}

protected static Excel generateFile()

{

int val1 = 10;

string path = @"C:\shailendra\AlbertaCalc\Copy of Alberta HRCL Refi APR Calculator.xls";

Excel ex = new Excel();

ex.Open(path,FileFormatType.Excel2003);

Worksheet sh = ex.Worksheets["DataSheet"];

Cells cells = sh.Cells;

cells["D27"].PutValue(val1);

return ex;

}


#2

Please post your file here. I will check it ASAP.

And have you tried the latest version of Aspose.Cells?