Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Apr 08, 2019 11:14 am

Hi, I used to use the following code when I want to fit all the columns to 1 page

Code: Select all
sheet.PageSetup.Zoom = False
sheet.PageSetup.FitToPagesWide = 1
sheet.PageSetup.FitToPagesTall = False


But in Spire.XLS, I can not set Zoom to False. It only allows integer 10-400. Do I still need to set this parameter?

The second question is about the margins, for sheet.PageSetup.TopMargin, bottom, left and right, what is the unit? How can I set my margins to excel's narrow?

Thank you.

ducphu
 
Posts: 11
Joined: Tue Nov 24, 2015 5:13 am

Tue Apr 09, 2019 9:59 am

Hi,
Thank you for your inquiry.
To fit all the columns to one page, setting the FitToPagesWide and FitToPagesTall is enough, there is no need to set the Zoom parameters.
Code: Select all
sheet.PageSetup.FitToPagesWide = 1;
sheet.PageSetup.FitToPagesTall = 0;

And the unit of margins in our Spire.XLS is inch. Generally, the unit of page margins of MS Excel is centimeter. Please refer to the following code to set the margins of page. If there is any question, please feel free to write back.
Code: Select all
//Set the margins, 1 inch = 2.54 cm.
sheet.PageSetup.TopMargin = 0.5;
sheet.PageSetup.LeftMargin = 0.5;
sheet.PageSetup.RightMargin = 0.5;
sheet.PageSetup.BottomMargin = 0.5;

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Fri Apr 12, 2019 7:21 am

Hi,

Did my code help you? Could you please give us some feedback at your convenience ? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Mon Apr 29, 2019 6:12 am

Thanks for your reply. I'm using that for my app. It works fine for most cases but when I have an excel file I attached, even I set
sheet.PageSetup.FitToPagesWide = 1
sheet.PageSetup.FitToPagesTall = 0

The last "=" character is still be on another page when it's printed. The weird thing is it's still one page under print preview.
Note: The file is auto generated from another app. The string "=================" is the value of a single cell, e.g. A2
Attachments
Book1.zip
(5.88 KiB) Downloaded 211 times

ducphu
 
Posts: 11
Joined: Tue Nov 24, 2015 5:13 am

Mon Apr 29, 2019 10:03 am

Hi

Thank you for your feedback
I printed your sample file with our physical printer (HP LasterJet P1007) and virtual printer (Microsoft XPS Document Writer). The printing output of both are only one page, I didn't reproduce your issue on my side. Please refer to the attached output from virtual printer. Thus, I suggest you try again with our latest Spire.XLS Pack(Hotfix) Version:9.4.6. If your issue still exists, please provide the following information to help us further look into it.
1. Your printer name(E.g. HP LasterJet P1007)。
2. The result when printing with Microsoft XPS Document Writer or other printer.
3. The system configuration(E.g. Win 7, 64 bit).
4. The region setting(E.g. China/Chinese).

Sincerely,
Nancy
E-iceblue support team
Attachments
result.zip
(59.72 KiB) Downloaded 210 times
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Wed May 01, 2019 9:46 am

Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.XLS