Print Area

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

Print Area

Postby darkcamper » Mon Sep 27, 2010 5:39 pm

Hi,

I've been unable to set the print Range. I have a worksheet with 3 columns and 64 rows and I only want to print the first two columns.
I've tried using the Workshett.PrintArea in this way:

Code: Select all
ws.PageSetup.PrintArea = "A1:B64"


But I wasn't successful. I've noticed that if I set the print range in Excel the property PrintRange is also updated. But Worksheet.PrintRange doesn't have a setter so I can't modify it.

What am I doing wrong?

Thanks in advance.
darkcamper
 
Posts: 13
Joined: Mon Sep 27, 2010 5:31 pm

Re: Print Area

Postby Flash » Thu Sep 30, 2010 7:23 am

Hello,

Thanks for your inquiry.
Please give me some time for research. I will inform you of the results here in this post.

Regards
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Re: Print Area

Postby Flash » Thu Sep 30, 2010 10:58 am

Hello,

I try to reproduce the problem, but there is no problem with print area, it work well.
Please download the attachment, it is the sample for your refereance.

Best regards
Attachments
14_PagesetupforPrintArea.zip
(11.74 KiB) Downloaded 353 times
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Re: Print Area

Postby darkcamper » Thu Sep 30, 2010 1:03 pm

Hi,

I've tried your sample and noticed it works perfectly when the workbook is saved with Excel 2003 (xls) format. The problem arises when you save it as an Excel 2007 (xlsx) file which is what I actually need.

Any suggestion?
darkcamper
 
Posts: 13
Joined: Mon Sep 27, 2010 5:31 pm

Re: Print Area

Postby Flash » Thu Sep 30, 2010 2:25 pm

Hello,

Thank you for addition information.
Please download the attachment, it is the sample for excel 2007.
Attachments
14_PagesetupforExcel2007.zip
(11.76 KiB) Downloaded 340 times
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Re: Print Area

Postby darkcamper » Thu Sep 30, 2010 3:51 pm

Hi again,

I've just tried your sample for Excel 2007 and it doesn't work properly. Even though it's supposed to set the print area to "A1:B2" it doesn't. When I open the generated file, the "Print Preview" shows all the worksheet rows and columns and, if I print it on paper, the result is the same.
darkcamper
 
Posts: 13
Joined: Mon Sep 27, 2010 5:31 pm

Re: Print Area

Postby Flash » Wed Oct 06, 2010 4:34 pm

Hello,

Which version of Spire.XLS for .NET you are using. Could you try the lastest version?

Best Regards.
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Re: Print Area

Postby darkcamper » Wed Oct 06, 2010 5:59 pm

Hi,

I've tried using version 5.5.2.36095 (NET 2.0) and 5.5.3.36087 (NET 3.5) which are installed by the installer you can download currenty at your download page. With both versions the results are the same: if output is excel 2003 everything works, if it's excel 2007 print area is not correctly set.
darkcamper
 
Posts: 13
Joined: Mon Sep 27, 2010 5:31 pm

Re: Print Area

Postby Flash » Fri Oct 08, 2010 3:25 pm

Hello,

Thank you for your additional information.
I can not reproduce the problem on my side. excel 2007 print area is correctly set.
attached images show the issue.

Best Regards.
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Re: Print Area

Postby darkcamper » Mon Oct 18, 2010 12:18 pm

Hi, I've looked inside the generated xlsx and I've found a difference in "xl\Workbook.xml" when I set PrintRange using Spire.XLS and when I set it inside Excel 2007:

Using Spire:

<definedNames>
<definedName name="Print_Area" localSheetId="0">
'Sheet1'!A1:B2</definedName>
</definedNames>

Using Excel 2007

<definedNames>
<definedName name="_xlnm.Print_Area" localSheetId="0">
Sheet1!$A$1:$B$5</definedName>
<definedName name="Print_Area" localSheetId="0">
Sheet1!A1:B2</definedName>
</definedNames>

I think the problem might be in this section of the file.
darkcamper
 
Posts: 13
Joined: Mon Sep 27, 2010 5:31 pm

Re: Print Area

Postby waldomirmarkgraf » Tue Dec 07, 2010 1:24 pm

is there an actual difference between "PageSetup.FitToPagesWide = 1" and "PageSetup.FitToPagesTall = 1"? is there a way to use those both to fit a page to one side, but maximize the output size? for example, if the text would be to long to be displayed on one page only, that it doesn't scale to the full width of the page, but only so far, that the whole page would still fit on one side?

to me it looks as if pageswide and pagestall doesn't do anything special, but just set to fit page. this of course is an unwanted behavior it you would want a long list printed over many pages but the columns of the list fit to the width of the page.
waldomirmarkgraf
 
Posts: 15
Joined: Mon Dec 06, 2010 12:14 pm

Re: Print Area

Postby Jason.Tan » Wed Dec 08, 2010 3:18 am

Hello,

The "Fit to" Page feature allow resize the worksheet or selection when you print so that it fits on the specified number of pages.
FitToPagesTall sets the height of the pages that the worksheet will be scaled, FitToPagesWide sets the width of the pages the
worksheet will be scaled.

Best Regards
Jason Tan
Technical Support / Developer,
e-iceblue Support Team
User avatar
Jason.Tan
 
Posts: 30
Joined: Tue May 25, 2010 7:17 am

Re: Print Area

Postby waldomirmarkgraf » Mon Dec 13, 2010 10:03 am

Jason.Tan wrote:Hello,

The "Fit to" Page feature allow resize the worksheet or selection when you print so that it fits on the specified number of pages.
FitToPagesTall sets the height of the pages that the worksheet will be scaled, FitToPagesWide sets the width of the pages the
worksheet will be scaled.

Best Regards

you do realize, that there is no specific "Fit to" Page method in spire.xls, right? there is only FitToPagesWide and FitToPagesTall and i can't make out any difference in the end result of the document, when using either. all those two methods seem to do, is set the fittopage property in the xls file.
waldomirmarkgraf
 
Posts: 15
Joined: Mon Dec 06, 2010 12:14 pm

Re: Print Area

Postby harry.support » Wed Dec 15, 2010 3:15 am

Hello,

If you use set the property FitToPagesWide, you need to also set the property FitToPagesTall to the number of page which will be printed. For example:
Code: Select all
sheet.PageSetup.FitToPagesWide = 1;
sheet.PageSetup.FitToPagesTall = 3;  //the actual number of page.

If the number of page is dynamic and too complicated to calculate, you can set the property FitToPagesTall to a biggish value, for example 10000. The max value of FitToPagesTall is 0x7FFF.
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar
harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 1 guest