0

I am getting this error in the error logs on Syncfusion excel file download. It happens few times a day everyday but i never get this error myself. The file does exist on the server and it works fine most of the time which makes it very hard for me to debug. The website is in .Net 4 on IIS and syncfusion dlls are referenced from the GAC. Syncfusion version is 8.303.0.21. Any idea on potential cause will be appreciated.

Code.

Private XlsIO As ExcelEngine
Private XlsWorkbook As IWorkbook
Dim str As String = Server.MapPath("Downloads/ExcelSpeedGen/excelfile.xls")
XlsIO = New ExcelEngine
XlsWorkbook = XlsIO.Excel.Workbooks.Open(str)
XlsRSheet = XlsWorkbook.Worksheets("raw data")
XlsRSheet.ImportDataTable(datatable, False, 2, 1, True)
XlsWorkbook.SaveAs("Excel.xls", ExcelSaveType.SaveAsXLS, Response, Syncfusion.XlsIO.ExcelDownloadType.PromptDialog)
XlsWorkbook.Close()

Error.

  System.Web.HttpException (0x80004005): Exception of type 'System.Web.HttpException' was 
  thrown. --->             System.Web.HttpUnhandledException (0x80004005): Exception of type 
  'System.Web.HttpUnhandledException' was thrown. ---> System.IO.FileNotFoundException: File   
  D:\inetpub\Secure\mywebsite\Downloads\ExcelSpeedGen\excelfile.xls could not be found. Please
  verify the file path. at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open
  (String fileName, ExcelOpenType openType, ExcelVersion version, ExcelParseOptions options) at 
  Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String filename) at 
  Default.form1_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) 
  at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at 
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean 
  includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at 
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean 
  includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, 
  Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at 
  System.Web.Util.AspCompatApplicationStep.System.Web.HttpApplication.IExecutionStep.Execute() at 
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at 
  System.Web.HttpAsyncResult.End() at ASP.ideasplusbaseline_aspx.EndProcessRequest(IAsyncResult ar) at 
  System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
Laurence
  • 7,633
  • 21
  • 78
  • 129

1 Answers1

0

Can you try to open the file (excelfile.xls) in Stream and pass the stream to XlsIO and if still the same issue reproducing in XlsIO then share the sample , it will better to sort the exact cause of this exception. Shared the code snippet for your reference.

Dim str As String = Server.MapPath("Downloads/ExcelSpeedGen/excelfile.xls")
Dim fileAsStream As FileStream = New FileStream(str, FileMode.Open, FileAccess.Read, FileShare.Read)
XlsIO = New ExcelEngine
XlsWorkbook = XlsIO.Excel.Workbooks.Open(fileAsStream)

Thanks, Sathish