Free Support Forum - aspose.com

How to only print the first page of an Excel Worksheet?

Hello,

How can I specify which page to print from a Worksheet? Using the SheetToImageByPage function that returns the Bitmap array is not going to work for me because in many scenarios I will be dealing with Worksheets that contain 1000 or more pages. This causes the application to slow to a halt relatively quickly.

Can I specify that I only want the first page of a Worksheet?

Thanks,

Ryan

Hi,

Yes, you can do it, see the sample code below:

Sample code:


Workbook workbook = new Workbook();
workbook.Open(“e:\test\myspreadsheet.xls”);
Worksheet worksheet = workbook.Worksheets[1];

//Apply different Image and Print options
ImageOrPrintOptions options = new ImageOrPrintOptions();
//Set Horizontal Resolution
options.HorizontalResolution = 200;
//Set Vertical Resolution
options.VerticalResolution = 200;
//Set TiffCompression
options.TiffCompression = TiffCompression.CompressionLZW;
//Set Image Format
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

//Take the image of the first page only in the second sheet.
worksheet.SheetToImageByPage(0,“e:\test\mypage.tiff”,options);



Thank you.