Ignore Errors while Rendering Excel to PDF with C++

Possible Usage Scenarios

Sometimes when you convert your Excel file to PDF, errors or exceptions occur and the conversion process terminates. You can ignore all such errors during the conversion process by using the PdfSaveOptions.PaginatedSaveOptions(PaginatedSaveOptions_Impl impl)* property. This way, the conversion process will complete smoothly without throwing any error or exception but the loss of data may occur. Therefore, please use this property only if the loss of data is not critical for you.

Ignore Errors while Rendering Excel to PDF

The following code loads the sample Excel file but the sample Excel file is erroneous and throws an error during conversion to PDF in 17.11 but since we are using PdfSaveOptions.PaginatedSaveOptions(PaginatedSaveOptions_Impl impl)* property, it does not throw an error. However, one rounded red arrow like shape as shown in this screenshot is lost.

todo:image_alt_text

Sample Code

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Output directory path
    U16String outDir(u"..\\Data\\02_OutputDirectory\\");

    // Path of input excel file
    U16String inputFilePath = srcDir + u"sampleErrorExcel2Pdf.xlsx";

    // Path of output pdf file
    U16String outputFilePath = outDir + u"outputErrorExcel2Pdf.pdf";

    // Load the Sample Workbook that throws Error on Excel2Pdf conversion
    Workbook wb(inputFilePath);

    // Specify Pdf Save Options - Ignore Error
    PdfSaveOptions opts;
    opts.SetIgnoreError(true);

    // Save the Workbook in Pdf with Pdf Save Options
    wb.Save(outputFilePath, opts);

    std::cout << "Workbook saved successfully with error ignored!" << std::endl;

    Aspose::Cells::Cleanup();
}