Hi
Would you please provide code snippet to convert excel range into PNG/EMF/JPEG?
We saw some examples on your forum but most of them are to convert Excel worksheet into PNG.
Thanks
H
nevermind, I am able to get it done.
Hi,
Thanks for your query.
Please see the sample code below for your for your reference for your requirements, kindly refer it and you may write your own code accordingly for your needs:
e.g
Sample code:
Workbook book = new Workbook(“e:\test\Book1.xls”);
Aspose.Cells.Worksheet sheet = book.Worksheets[0];
//Specify your print area.
sheet.PageSetup.PrintArea = “A1:B5”;
//Set left, top, right, bottom margins to 0
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.TopMargin = 0;
sheet.PageSetup.BottomMargin = 0;
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Png;
imgOptions.OnePagePerSheet = true;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
SheetRender sr = new SheetRender(sheet, imgOptions);
for (int j = 0; j < sr.PageCount; j++)
{
sr.ToImage(j, “e:\test2\onlycellrange_” + sheet.Index + j + “.png”);
}
Hope, this helps a bit.
Thank you.