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

Free Support Forum - aspose.com

Save Complete WorkSheet to one page

Hi,


I’m relatively new to Aspose Cells.
I’m trying to save a complete Worksheet to one page.
I’ve found multiple ways to do so:

1. From the Documentation:

Workbook wb = new Workbook(“C:\Book1Test.xls”);
Worksheet sheet = wb.Worksheets[0];
Bitmap bitmap = sheet.SheetToImage();
bitmap.Save(“C:\ExampleUsing sheet.SheetToImage.tiff”, ImageFormat.Tiff);


2. From the forum and other sources:

Workbook wb = new Workbook(“C:\Book1Test.xls”);
Worksheet sheet = wb.Worksheets[0];
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
imgOptions.HorizontalResolution = 100;
imgOptions.VerticalResolution = 100;
imgOptions.TiffCompression = TiffCompression.CompressionLZW;
imgOptions.OnePagePerSheet = true;

SheetRender render = new SheetRender(sheet, imgOptions);
render.ToTiff(“ExampleUsing sheetRender.ToTiff.tiff”);



Here is my problem:
The first function is deprecated and should be avoided.
The second method doesn’t print the complete worksheet. The pages gets the size of the WorkSheet, but half of it is empty.

Attached are the examples I used.

Is there a solution to my problem?

Sincerely,

G. Smulders
Hi G. Smulders,
Thank you for providing us the details. It is the default behavior, If you try out "PrintPreview" in MS Excel the sheet will be divided into two pages.
Furthermore, you can use the PrintArea of PageSetup like below:

wb1.PageSetup.PrintArea = "A1:I33";

If there is any thing which is unclear, please feel free to reach us.
Thanks,

Hi Salman Shakeel,


Thanks for your advice. The PrintArea settings helped.

Then the problem was that it still only prints the first page.
Up to a point that can be corrected by setting the PaperSize property.
But if the sheet is to large, that won’t work either.

My problem for now is solved, thank you very much.

Sincerely,

G. Smulders

Hi,

Just to confirm, you might have already known this :slight_smile:

You can render images for all the pages (by specifying its index) of the large worksheet, see the code segment below:

//…

SheetRender sr = new SheetRender(sheet, imgOptions);
for (int j = 0; j < sr.PageCount; j++)
{

sr.ToImage(j, “e:\test\MyTest_image” + j + “.tif”);
}


Moreover, I will update the online documentation regarding Sheet-to_Image feature (using SheetRender APIs) soon.

Have a good day!

Hi,


Yes I already knew of this function :slight_smile:

I’m dealing with a form that is made in Excel that needs to be filled in and sent back.
When receiving, it may happen that the column sizes are changed, so that it won’t print on one page.

I solved this problem by using:
sheet.PageSetup.FitToPagesWide = 1;

Thank you very much for your time, and a good day to you too.

Sincerely,

G. Smudlers