Excel を PDF にレンダリングする際のエラーを無視する
Contents
[
Hide
]
考えられる使用シナリオ
Excel ファイルを PDF に変換すると、エラーまたは例外が発生し、変換プロセスが終了することがあります。を使用して、変換プロセス中にそのようなエラーをすべて無視できます。PdfSaveOptions.IgnoreError財産。このようにして、変換プロセスはエラーや例外をスローすることなくスムーズに完了しますが、データが失われる可能性があります。したがって、データの損失が重大でない場合にのみ、このプロパティを使用してください。
Excel を PDF にレンダリングする際のエラーを無視する
次のコードは、サンプル Excel ファイルしかし、サンプルの Excel ファイルには誤りがあり、実行中にエラーがスローされます。PDFに変換 17.11では使用していますが、使用しているため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); |