Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes converting large Excel files can take some time. During this time, you might want to show the document conversion progress instead of just a loading screen to enhance the usability of your application. Aspose.Cells supports tracking document conversion progress by providing the IPageSavingCallback interface. The IPageSavingCallback interface provides PageStartSaving and PageEndSaving methods that you can implement in your custom class. You may also control which pages are rendered as demonstrated in the TestPageSavingCallback custom class.
The following code sample loads the source Excel file and prints its conversion progress in the console by using the TestPageSavingCallback custom class that implements the IPageSavingCallback interface. The output file generated is attached for your reference.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
class TestTiffPageSavingCallback : public IPageSavingCallback {
public:
void PageStartSaving(PageStartSavingArgs& args) override {
// Implement page start saving logic here
}
void PageEndSaving(PageEndSavingArgs& args) override {
// Implement page end saving logic here
}
};
int main() {
Aspose::Cells::Startup();
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
Workbook workbook(srcDir + u"sampleUseWorkbookRenderForImageConversion.xlsx");
ImageOrPrintOptions opts;
opts.SetPageSavingCallback(new TestTiffPageSavingCallback());
opts.SetImageType(Aspose::Cells::Drawing::ImageType::Tiff);
WorkbookRender wr(workbook, opts);
wr.ToImage(outDir + u"DocumentConversionProgressForTiff_out.tiff");
std::cout << "Document converted to TIFF successfully!" << std::endl;
Aspose::Cells::Cleanup();
return 0;
}
The following is the code for the TestTiffPageSavingCallback custom class.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Rendering;
class TestTiffPageSavingCallback : public IPageSavingCallback
{
public:
void PageStartSaving(PageStartSavingArgs& args) override
{
std::cout << "Start saving page index " << args.GetPageIndex() << " of pages " << args.GetPageCount() << std::endl;
// Don't output pages before page index 2.
if (args.GetPageIndex() < 2)
{
args.SetIsToOutput(false);
}
}
void PageEndSaving(PageEndSavingArgs& args) override
{
std::cout << "End saving page index " << args.GetPageIndex() << " of pages " << args.GetPageCount() << std::endl;
// Don't output pages after page index 8.
if (args.GetPageIndex() >= 8)
{
args.SetHasMorePages(false);
}
}
};
Start saving page index 0 of pages 10</br>
End saving page index 0 of pages 10</br>
Start saving page index 1 of pages 10</br>
End saving page index 1 of pages 10</br>
Start saving page index 2 of pages 10</br>
End saving page index 2 of pages 10</br>
Start saving page index 3 of pages 10</br>
End saving page index 3 of pages 10</br>
Start saving page index 4 of pages 10</br>
End saving page index 4 of pages 10</br>
Start saving page index 5 of pages 10</br>
End saving page index 5 of pages 10</br>
Start saving page index 6 of pages 10</br>
End saving page index 6 of pages 10</br>
Start saving page index 7 of pages 10</br>
End saving page index 7 of pages 10</br>
Start saving page index 8 of pages 10</br>
End saving page index 8 of pages 10</br>Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.