[英]Convert from Excel to CSV via asp.net (C#) under IIS
I have simple procedure for converting xlsx to csv. 我有将xlsx转换为csv的简单过程。
public static void ConvertExcelToCsv(string source, string destination, int sheetNumber = 1)
{
if (File.Exists(destination)) File.Delete(destination);
Excel.Application xl = new Excel.Application();
xl.DisplayAlerts = false;
Excel.Workbook workbook = xl.Workbooks.Open(source);
// workbook.Close(true);
workbook.SaveAs(destination, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV);
object misValue = System.Reflection.Missing.Value;
if (workbook != null)
{
workbook.Close(false, Type.Missing, Type.Missing);
xl.Workbooks.Close();
Marshal.ReleaseComObject(workbook);
}
xl.Quit();
GC.Collect();
Marshal.FinalReleaseComObject(xl);
}
Everything works fine on my local machine and also local IIS. 在我的本地计算机和本地IIS上,一切正常。 But after uploading onto web server seems to don't work.
但是上传到Web服务器后似乎不起作用。 Everything what it does is processing about 3 mins and then time out.
它所做的所有事情都要处理大约3分钟,然后超时。
I also allowed permissions in Component 我还允许组件中的权限
Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application -> IIS_IUSRS
and also created Desktop folders 并创建了桌面文件夹
C:\\Windows\\SysWOW64\\config\\systemprofile\\
and also in 32bit :-) 也是32bit的:-)
So right now, I have no idea, why it doesn't work. 所以现在,我不知道为什么它不起作用。 Do you have similar experience with this or can you provide some hint what should I do, please.
您对此有类似的经验吗,或者可以提供一些提示,请问我该怎么做。
What is the exact error that you receive? 您收到的确切错误是什么? Check your IIS logs and the Application event log for specific errors.
检查IIS日志和应用程序事件日志中的特定错误。
A couple things to check for: 需要检查的几件事:
source
and destination
source
和destination
引用的路径具有适当的权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.