Skip to end of metadata
Go to start of metadata

 

 

Aspose.Cells allows you to export a worksheet from workbook and convert it into different formats. This article explains how to convert a worksheet to different formats.

Contents Summary
 

Converting Worksheet to Image

Worksheets contain data that you want to analyze. For example, a worksheet can contain parameters, totals, percentages, exceptions, and calculations.

As a developer, you might need to present worksheets as images. For example, you might need to use an image of a worksheet in an application or web page. You might want to insert an image into a Microsoft Word document, a PDF file, a PowerPoint presentation or some other document type. Simply put, you want a worksheet rendered as an image so that you can use it somewhere else.

Aspose.Cells supports converting Excel worksheets to images. To use this feature, you need to import the Aspose.Cells.Rendering namespace to your program or project. It has several valuable classes for rendering and printing, for example SheetRender, ImageOrPrintOptions, WorkbookRender and others.

The Aspose.Cells.Rendering.SheetRender class represents a worksheet to render as images. It has an overloaded method, ToImage, that can convert a worksheet to image file(s) with different attributes or options. It returns a System.Drawing.Bitmap object and you can save an image file to disk or stream. Several image formats are supported, for example BMP, PNG, GIF, JPG, JPEG, TIFF, EMF.

The following code snippet shows how to convert a worksheet in an Excel file to an image file.

 

At present, the API for converting worksheets to images does not support 3D bubble charts.

Converting Worksheet to SVG

SVG stands for Scalable Vector Graphics. SVG is a specification based on XML standards for two-dimensional vector graphics. It is an open standard that has been under development by the World Wide Web Consortium (W3C) since 1999.

Aspose.Cells for .NET has been able to convert worksheets to SVG image since version 7.1.0. The following code snippet shows how to convert a worksheet in an Excel file to SVG image file.

Sample Code

// Instantiate a workbook
var workBook = new Workbook();
 
// Put sample text in the first cell of first worksheet in the newly created workbook
workBook.Worksheets[0].Cells["A1"].Value = "DEMO TEXT ON SHEET1";
 
// Add second worksheet in the workbook
workBook.Worksheets.Add(SheetType.Worksheet);
 
// Set text in first cell of the second sheet
workBook.Worksheets[1].Cells["A1"].Value = "DEMO TEXT ON SHEET2";
 
// Set currently active sheet incex to 1 i.e. Sheet2
workBook.Worksheets.ActiveSheetIndex = 1;
 
// Save workbook to SVG. It shall render the active sheet only to SVG
workBook.Save(@"Demo.svg");

 

 

Labels
  • No labels