生成された.xlsxスプレッドシートをPDFとしてエクスポートしたい。画像をエクスポートしない名前を付けて保存()ExportAsFixedFormat() Microsoft Office Interop Excel ExportAsFixedFormat - 非常に遅い、画像がロードされない
- エクスポート文書は、両方の方法のために非常に遅いです: は、私は2つの問題を抱えています。
IISでASP.NETサーバーでコードを実行しています。
https://github.com/aardvarkss/ExcelPDFExportはまた、私はEPPlusとの.xlsxファイルを生成します。このリポジトリからhttps://support.comodo.com/index.php?/Knowledgebase/Article/View/1129/66/access-denied-exception-from-hresult-0x80070005-e_accessdenied
コードがエラーなしで動作します。それは、ここで述べているように
は、すでにアクセス権を設定しました。コード:
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbooks excelWorkbooks = app.Workbooks;
Microsoft.Office.Interop.Excel.Workbook wkb = excelWorkbooks.Open(this.tempExcelFilePath);
foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in wkb.Sheets)
{
sheet.SaveAs(this.tempPdfFilePath); // Saves the PDF correct AS I want But it cannot finish the task (waiting around 3 mins)
sheet.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, this.tempPdfFilePath); // Export PDF without image (image currently cannot be displayed), Also slow
}
wkb.SaveAs(this.tempPdfFilePath); // Waiting too long and cannot be finished
wkb.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, "C:\\Users\\user222\\Desktop\\Sample.pdf"); // Waiting too long and cannot be finish the task
// Closes the EXCEL.exe process in windows. If it not closes it cause errors.
wkb.Close(SaveChanges: false);
excelWorkbooks.Close();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(wkb);
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
それはとても遅いですなぜ任意のアイデア?私の問題を解決する方法は?
今日は遅い読み込みが開始されました。それ以前は、読み込みが遅いというこの問題はありません。
Interopは、サーバーアプリケーションで使用するように設計されておらず、推奨もされていません。孤立したEXCEL.EXEが残っていない場合は、TaskManagerをチェックインしてください。 – Alex
'new Microsoft.Office.Interop.Excel.Application();'行に達する直前にデバッグを行うと、タスクマネージャにEXCEL.EXEプロセスはありません。 – mihkov
それは、それが今日以前に働いていたので、Excelまたはソースファイルのいずれかでなければならないと思います。サーバを再起動して、それが何か変わるかどうか確認してください。 – Alex