We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot scale worksheet with content across multiple pages to single page

Hi,



I have an excel file with two sheets into it. First Sheet is spanned across multiple pages, i.e. 4 pages. I am trying to render this sheet into a .bmp image. However, even after I am using below code to scale content of sheet to one page, the image rendered is not having complete content.

sheet.PageSetup.FitToPagesTall = 1;

sheet.PageSetup.FitToPagesWide = 1;



Below is the code snippet that I am using.

//initializing Aspose license for Excel Application

AsposeExcel.License license = new AsposeExcel.License();

license.SetLicense(“Aspose.Total.lic”);



//initializing Aspose Excel Workbook object with the provided excel template.

AsposeExcel.Workbook workBook = new AsposeExcel.Workbook(sourcePath);



//initializing image saving options and defining the image format.

AsposeExcel.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();

options.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;

options.OnePagePerSheet = true;

var sheet = workBook.Worksheets[0];

Orientation = Convert.ToString(sheet.PageSetup.Orientation);

sheet.PageSetup.FitToPagesTall = 1;

sheet.PageSetup.FitToPagesWide = 1;

AsposeExcel.Rendering.SheetRender sheetRender = new SheetRender(sheet, options);

sheetRender.ToImage(0, @“D:\Temp\SheetImage.bmp”)



I have attached the excel file I am using.

Hi Karunish,

Thanks for your posting and using Aspose.Cells.

Actually, your worksheet Print Area has been set as B:D. It will therefore print only the contents in this area. If you clear it, then it will print the entire worksheet.

Please see the following code. I have attached the output sheet image and screenshot showing the print area for your reference.

Please see the red line used in clearing this print area.

C#


Workbook workbook = new Workbook(path);


Worksheet worksheet = workbook.Worksheets[0];


//Clear the print area from page setup

worksheet.PageSetup.PrintArea = null;


Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();

options.OnePagePerSheet = true;

options.ImageFormat = ImageFormat.Png;


SheetRender sr = new SheetRender(worksheet, options);

sr.ToImage(0, path + “.out.png”);