Hi,
we’re using Aspose.cells 8.6.3 for providing Excel and Pdf (saveAs) files, based on Excel templates.
I need to compute and set the zoom of a page (page setup of the worksheet) depending on :
- width of the defined print area (sum of columns width of print area … in “point” unit)
- paper type and orientation
- left and right margin
I know how to get all this elements.
But does method exist in Aspose.Cells to get :
- page width in “point” unit depending on paper type and orientation.
or
- page width in “cm” or “inch” unit, the type of the uniy depending on paper type and orientation.
- and, in this case, what is conversion factor from “cm” to “point” or “inch” to "point"
Regards,
Eric Hamel
Hi Eric,
Worksheet sheet = book.getWorksheets().get(0);
ImageOrPrintOptions options = new ImageOrPrintOptions();
SheetRender render = new SheetRender(sheet, options);
float [] size = render.getPageSize(0);
System.out.println("Width: " + size[0] + " Height: " + size[1]);
Hi Babar,
thank you for the answer.
but it doesn’t seem to fit with my needs.
First, what is the unit returned by the method “worksheet.getCells().getColumnWidth(i)” ?
I saw you’ve got same methods to get column width in inches or pixels.
Second point :
I don’t understand why we need to set horizontal and vertical resolution to get the pageSize.
That’s why i think the expression of my needs was wrong.
I need to know the size of the selected paper on the page setup of the sheet.
For example :
A4 -> width 210mm / height 297mm
A3 -> width 297mm / height 420mm
Letter -> width 8,5inch / height 11inch
…
Then, i can substract right and left margin (pageSetup.getRightMargin() & pageSetup.getLeftMargin()) and i have the size of the possible printing area of my page.
this is "myPageWidth"
If i want to see colums A to Z on a page, i just have to sum columns width from A to Z = "myColumnsWidth"
And then i can set the worksheet.getPageSetup().setZoom(value) with the result of :
myPageWidth / myColumnsWidth * 100
that’s why, I need a way to know the size of the paper and how to convert it in same unit of column width and height.
Regards,
Eric Hamel
Hi Eric,
Hi Babar,
thank you for your explanations.
It works fine !!!
For conversions inch <-> point, i use ConvertUtil java class from Aspose.Words.
Wish you an Happy New year.
regards,
Eric Hamel
Hi Eric,