0

我在 Syncfusion excel 文件下载的错误日志中收到此错误。它每天发生几次,但我自己从来没有遇到过这个错误。该文件确实存在于服务器上,并且大部分时间都可以正常工作,这使我很难调试。该网站位于 IIS 上的 .Net 4 中,并且从 GAC 引用了 syncfusion dll。Syncfusion 版本是 8.303.0.21。任何关于潜在原因的想法将不胜感激。

代码。

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()

错误。

  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)
4

1 回答 1

0

您能否尝试在 Stream 中打开文件(excelfile.xls)并将流传递给 XlsIO,如果在 XlsIO 中重现相同的问题,然后共享示例,最好对导致此异常的确切原因进行排序。共享代码片段供您参考。

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)

谢谢, 萨西什

于 2014-05-05T10:27:30.060 回答