Free Support Forum - aspose.com

Preview and Print in ASP.NET

I have an ASP.NET application where I’m previewing and printing Word documents, which works great. Functions include zooming, displaying specific pages, and specifying pages and number of prints. I would like to do the same for Excel documents, but I’m struggling with the following:

1. How do I specify the zoom ratio for previewing a worksheet? Does the PageSetup affect the SheetToImage() method?
2. How do I display a specific page of a worksheet as a preview?
3. How do I specify how many pages to print and which pages to print?

Thanks for the help!

Hi,

Well, I think you may try some pagesetup options.

kruste:

1. How do I specify the zoom ratio for previewing a worksheet? Does the PageSetup affect the SheetToImage() method?


Well, by default, SheetToImage method will take the image of the entire sheet. But you may set the scaling factor using PageSetup.Zoom attribute for your need.

kruste:

2. How do I display a specific page of a worksheet as a preview?

Well, you may try to set your desired printable area using PageSetup.PrintArea property. It will specify the preview of the sheet. Aspose.Cells will take the image of that area which is shown in the preview in MS Excel.

Sample code:

Workbook wb = new Workbook();

wb.Open(@"f:\test\dataBook.xls");

wb.Worksheets[0].PageSetup.PrintArea = "A1:H11";

wb.Worksheets[0].PageSetup.Zoom = 100;

Bitmap bitmap = wb.Worksheets[0].SheetToImage();

bitmap.Save(@"f:\test\image.emf", System.Drawing.Imaging.ImageFormat.Emf);

Thank you.

Any thoughts on question #3?

Hi,

Thank you for considering Aspose.

For you requirement # 3, I am afraid Aspose.Cells does not support it currently. We only export the entire worksheet or print area to an image.

Thank You & Best Regards,

Hi,

Thank you for considering Aspose.

kruste:
3. How do I specify how many pages to print and which pages to print?

To update you, we have supported Sheet2ImageByPage API. Please try the attached latest version of Aspose.Cells and see the following documentation link for sample code and details about the feature.

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/converting-worksheet-to-image-worksheet-to-image-by-page.html

Thank You & Best Regards,