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.

Sat Jan 18, 2025 12:13 pm

When using Spire.XLS, there are multiple sheets, and the page orientations are both horizontal and vertical. However, only one orientation is used when printing. How can I set different paper orientations for different sheets when printing?

The following does not work:

sheet = workbook.Worksheets[1];
pageSetup = sheet.PageSetup;
pageSetup.Orientation = PageOrientationType.Portrait;
sheet = workbook.Worksheets[2];
pageSetup = sheet.PageSetup;
pageSetup.Orientation = PageOrientationType.Landscape;

PrintDialog dialog = new PrintDialog();
dialog.UserPageRangeEnabled = true;
PageRange rang = new PageRange(1, 3);
dialog.PageRange = rang;
PageRangeSelection seletion = PageRangeSelection.UserPages;
dialog.PageRangeSelection = seletion;
if (dialog.ShowDialog() == true)
{
workbook.PrintDocument.Print();
}

xiaoyu4649
 
Posts: 3
Joined: Sat Jan 18, 2025 12:02 pm

Mon Jan 20, 2025 10:53 am

Hello,

Thank you for your letter. To set different paper orientations for different sheets when printing, please add the following setting.
Code: Select all
......
  workbook.ConverterSetting.PrintWithSheetPageSetting = true;
  workbook.PrintDocument.Print();

If you have any other questions, please feel free to contact.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Fri Jan 24, 2025 9:50 am

Hello,

Greetings from E-iceblue. Could you please let us know how is the issue going? I would appreciate that if you could give us some feedback.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Sun Jan 26, 2025 12:41 pm

Lisa.Li wrote:Hello,

Greetings from E-iceblue. Could you please let us know how is the issue going? I would appreciate that if you could give us some feedback.

Sincerely,
Lisa
E-iceblue support team



I tried it as you suggested, and the test can print different pages normally, and the printing effect is good, thank you!

xiaoyu4649
 
Posts: 3
Joined: Sat Jan 18, 2025 12:02 pm

Mon Jan 27, 2025 2:02 am

Hello,

Glad to hear that, if there is anything else we can do for you in the future, just feel free to contact!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS