Set PrintSizeType

I’m working with Aspose Cells, and I’m searching, where I’m able to use the PrintSizeType enum, because its described in the API, but I don’t found an example how to use it.

Thanks for help.


Thanks for considering Aspose.

Well, Its PaperSizeType not PrintSizeType. Check the codes below:


//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Setting the paper size to A4
worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4;


//Instantiating a Workbook object
Workbook workbook =new Workbook();
//Accessing the first worksheet in the Excel file
Worksheets worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.addSheet();
//Setting the paper size to A4
PageSetup pageSetup = sheet.getPageSetup();

And it is there in the wiki docs, for reference, please check:

Thank you.

Thanks for the answer.

But that’s not what I meant.

The PrintTypeSize offers the possiblity to fit the content of the worksheet to fit at one page.

That’s what I like to know. How am I be able to get this result.



I think you are talking about fitting pages wide and tall. If you need to fit the contents of the worksheet to desired number of pages, you can do it by using the FitToPagesTall and FitToPagesWide properties of the PageSetup class. These properties are also used for the scaling of worksheets.

Please check "FitToPages Options" topic in the doc

Thank you.

hi, yes I’ve tried it with the FitToPagesTall and FitToPagesWide properties, but the didnot work.
I’ve set FitToPagesWide = 1 and FitToPagesTall =1 , but some text was cutted of.

So i was looking for another option and find the PrintSizeType in the API and thought this would solve my problem.

So, are there any problems with the FitToPagesWide property or may i’m doing something wrong?


Well, there is no problem with FitToPagesTall and FitToPagesWide. It works in the same way as MS Excel does.

Could you paste your code and attach the output excel file to show the issue.

And by the way you are talking about PrintSizeType enum, this is used to specify the printable chart size only.

Thank you.

if used the following code:

Aspose.Cells.Workbook docxls = new Workbook();

for (int k = 0; k < docxls.Worksheets.Count; k++)
docxls.Worksheets[k].PageSetup.FitToPagesWide = 1;
docxls.Worksheets[k].PageSetup.FitToPagesTall = 1;

MemoryStream docstream = new MemoryStream();
docxls.Save(docstream, FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf = new Pdf();
pdf.BindXML(docstream, null);
pdf.Save(outDir +"\" + pdfname);

May I must set some values from the pdf?


Please try the attached version.

Thank you.

Thanks a lot. Now the fitting on the last sheet works.

But now the second sheet (“some diags”) is not fitted correctly.
And another problem with this sheet is, that the diagramm legend not uses the correct name.


Thanks for the info, We will check and figure out the issue soon. We will attach a fix here.

Thank you.


Please try this fix.

We have seen your another post. We have not fix the bug of that post.

The fitting seems to work now. Thanks.

I hope you find a solution for the other problems.