Converting Worksheet to Image and Worksheet to Image by Page

Using Aspose.Cells to Convert Worksheet to Image File

This article shows how to create a console application in Visual Studio, convert a worksheet to an image, and convert a worksheet into one image for each worksheet with a few and simplest lines of code using the Aspose.Cells API.

You need to import the Aspose.Cells.Rendering namespace to your program/project. It has several valuable classes, such as SheetRender, ImageOrPrintOptions, WorkbookRender, and so on. The Aspose.Cells.Rendering.SheetRender class represents a worksheet to render images for the worksheet and has an overloaded ToImage method that can convert a worksheet to image files directly with any attributes or options set. It can return a System.Drawing.Bitmap object and you can save an image file to the disk/stream. Several image formats are supported, for example, BMP, PNG, GIF, JPG, JPEG, TIFF, EMF, and others.

This article explains how to:

  • Convert a worksheet to an image
  • Convert every page in a worksheet to an image

This task shows how to use Aspose.Cells to convert a worksheet from a template workbook to an image file.

Setup Project

  1. First, download Aspose.Cells for .NET.
  2. Install it on your development computer. All Aspose components, when installed, work in evaluation mode. The evaluation mode has no time limit and it only injects watermarks into produced documents. Now start Visual Studio.Net and create a new console application. This example uses a C# console application, but you can use VB.NET too. Add reference to Aspose.Cells into created project.

Convert Worksheet to Image File

I created a new workbook in Microsoft Excel and added some data in the first worksheet: Testbook.xlsx (1 worksheet). Next, convert the template file’s worksheet Sheet1 to an image file called SheetImage.jpg.

Following is the code used by the component to accomplish the task. It converts Sheet1 in Testbook.xlsx to an image file to explain how easy this conversion is.

Using Aspose.Cells to Convert Worksheet to Image File by Page

This example shows how to use Aspose.Cells to convert a worksheet from a template workbook that has several pages to one image file per page.

Convert Worksheet to Image by page

I created a new workbook in Microsoft Excel and added some data in the first worksheet: Testbook2.xlsx (1 worksheet).

Now, convert the template file’s worksheet Sheet1 to image files (one file per page). As I already created the console application to perform the copy task, I will skip those console application creation steps and directly move to the worksheet conversion steps.

Following is the code used by the component to accomplish the task. It converts Sheet1 in Testbook2.xls to image files by page.