Excel を PDF にレンダリングする際のエラーを無視
Contents
[
Hide
]
可能な使用シナリオ
ExcelファイルをPDFに変換する際に、エラーや例外が発生して変換プロセスが終了することがあります。PdfSaveOptions.IgnoreErrorプロパティを使用して変換中のすべてのエラーを無視することができます。これにより、変換プロセスはエラーや例外をスローすることなくスムーズに完了しますが、データの損失が発生する可能性があります。したがって、データの損失が重要でない場合にのみこのプロパティを使用してください。
Excel を PDF にレンダリングする際のエラーを無視
次のコードは、サンプルExcelファイルを読み込みますが、サンプルExcelファイルにエラーがあり、17.11でPDFに変換する際にエラーが発生しますが、PdfSaveOptions.IgnoreErrorプロパティを使用しているため、エラーは発生しません。ただし、このスクリーンショットに表示されているように、1つの赤い矢印のような形が失われます。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load the Sample Workbook that throws Error on Excel2Pdf conversion | |
Workbook wb = new Workbook("sampleErrorExcel2Pdf.xlsx"); | |
//Specify Pdf Save Options - Ignore Error | |
PdfSaveOptions opts = new PdfSaveOptions(); | |
opts.IgnoreError = true; | |
//Save the Workbook in Pdf with Pdf Save Options | |
wb.Save("outputErrorExcel2Pdf.pdf", opts); |