There can be many reasons for converting Excel files to images. For instance, you can add images to web pages, PDFs, Word Documents, PowerPoint Presentations, etc. In this article, you will learn how to convert Excel files to images with C++.
C++ Excel to Image Converter API
Aspose.Cells for C++ is a native C++ library that enables you to create, manipulate and convert spreadsheets without requiring Microsoft Excel or Office Automation. Furthermore, the API provides built-in support to convert Excel spreadsheets to different formats as well. You can install Aspose.Cells for C++ API by either using the NuGet package or downloading the API directly.
Excel to Image Conversion with C++
Aspose.Cells for C++ allows you to convert Excel spreadsheets into various popular image formats. The following are the supported output image formats:
You can use the following steps to convert Excel files to images.
- Firstly, load the Excel file with the IWorkbook class.
- Create an instance of the IImageOrPrintOptions class.
- Set the image type by passing the ImageFormat enumeration to IImageOrPrintOptions->SetImageFormat() method.
- Set other options like horizontal and vertical resolution with the IImageOrPrintOptions class.
- Create an instance of the IWorksheet class with the worksheet that you want to convert.
- Make an object of the ISheetRender class by passing the IWorksheet and the IImageOrPrintOptions instances as parameters.
- Get the number of pages in the worksheet with the ISheetRender->GetPageCount() method.
- Finally, loop through the pages and save each page as an image with the ISheetRender->ToImage() method.
The following example code snippet shows how to convert Excel files to images using C++.
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
To conclude, you have learned how to convert Excel spreadsheets to images using C++. By using Aspose.Cells for C++ API, you can convert Excel files to various popular image formats including PNG, TIFF, SVG, GIF, JPEG, etc. To explore more about the API, use the API documentation.