string path=Server.MapPath("../ExcelTemplate/DownloadExcelFiles/FacilitySetup" + ss + ".xls");
log.append("Mapped Path"+path, 100);
log.append("Start to SaveAs Worksheet", 100);
try
{
ThisWorkBook.SaveAs("" + Server.MapPath("../ExcelTemplate/DownloadExcelFiles/FacilitySetup" + ss + ".xls") + "", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, missing, missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
missing, missing, missing, missing, missing);
//ThisWorkBook.SaveAs(path, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, missing, missing, false, false,
// Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
}
catch (Exception exceptionObj)
{
log.append("Exception During SaveAs" + exceptionObj.ToString(),100);
}
log.append("Worksheet SaveAs Successfully", 100);
Note:
How to solve it?
尝试不使用Server.MapPath,因为您已经有了物理路径
It sounds like you have a deadlock (and not an exception). As someone said in a comment, using Office interop in a server environment is a very bad idea. See: http://support.microsoft.com/kb/257757 for a lot of information as to why. Check out ClosedXML
I recently encountered a problem with downloading .xls files. Explanation is here: http://support.microsoft.com/kb/2123563 . Who knows, it might be a problem here as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.