#pragma once #include "Aspose.Cells.h" class ConvertExcelToSVG { public: void ConvertExcelToSVGInCplusCplus() { // Set the Aspose.Cells license to create output SVG without watermark intrusive_ptr<License> rowHeightLicense = new License(); rowHeightLicense->SetLicense(new String("Aspose.Cells.lic")); // Load input workbook intrusive_ptr<Aspose::Cells::IWorkbook> targetWorkbook = Factory::CreateIWorkbook(new String("ConvertExcelToSVG.xlsx")); // Access target worksheet say third one intrusive_ptr<Aspose::Cells::IWorksheet> thirdSheet = targetWorkbook->GetIWorksheets()->GetObjectByIndex(2); // Create object to set image options intrusive_ptr<Aspose::Cells::Rendering::IImageOrPrintOptions> OptionsForRenderingImage = Factory::CreateIImageOrPrintOptions(); // Specify SVG save format OptionsForRenderingImage->SetSaveFormat(Aspose::Cells::SaveFormat::SaveFormat_SVG); // Autofit Cells based on the data OptionsForRenderingImage->SetCellAutoFit(true); // Specify values for the horizontal and vertical resolution OptionsForRenderingImage->SetHorizontalResolution(300); OptionsForRenderingImage->SetVerticalResolution(300); // Using the CreateISheetRender() function, render the sheet by providing the sheet reference and image options intrusive_ptr<Aspose::Cells::Rendering::ISheetRender> sheetRender = Factory::CreateISheetRender(thirdSheet, OptionsForRenderingImage); // Get page count Aspose::Cells::Systems::Int32 totalPages = sheetRender->GetPageCount(); // Initialize string builder object for string concatenation intrusive_ptr<Aspose::Cells::Systems::Text::StringBuilder> stringBuilder = new Aspose::Cells::Systems::Text::StringBuilder(); // Parse throught all the pages to convert them to SVG one by one for (int counter = 0; counter < totalPages; counter++) { // Set the path for output image with string appending stringBuilder->Clear(); stringBuilder->Append(counter); stringBuilder->Append((StringPtr)new String("_Page.svg")); // Convert Excel to SVG image sheetRender->ToImage(counter, stringBuilder->ToString()); } } };