Excel Question

Excel Question

Postby Jeff Barnes » Sun Feb 25, 2007 2:41 pm

Hi Everybody,

Does anyone know how to force a "Page Break" in Excel via FW ?


Thanks,

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Excel Question

Postby Enrico Maria Giordano » Sun Feb 25, 2007 3:31 pm

This is a working sample:

Code: Select all  Expand view
#define xlPageBreakManual -4135
#define xlPageBreakNone -4142


FUNCTION MAIN()

    LOCAL oExcel := CREATEOBJECT( "Excel.Application" )

    LOCAL oSheet

    oExcel:WorkBooks:Add()

    oSheet = oExcel:ActiveSheet

    oSheet:Cells( 1, 1 ):Value = "This is the first page"

    oSheet:Rows( 2 ):PageBreak = xlPageBreakManual

    oSheet:Cells( 2, 1 ):Value = "This is the second page"

    oExcel:Visible = .T.

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sun Feb 25, 2007 3:42 pm

Thanks Enrico

I did some more searching and also found the solution:
(similar to yours)

oSheet:Rows( nTopPage ):Set("PageBreak",-4135)

What does the xlPageBreakNone do?


Also, for anyone who is interested, I found a list of the disserent numbers associated with the excel commands (scroll down about 1/4 of the page):


[url]
http://nerds-central.blogspot.com/2007_ ... chive.html
[/url]


Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Sun Feb 25, 2007 3:50 pm

Jeff Barnes wrote:What does the xlPageBreakNone do?


It removes the page break, what else? :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sun Feb 25, 2007 11:24 pm

I figured that out as soon as I hit the send button :wink:

Thanks Enrico.



Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Gale FORd » Mon Feb 26, 2007 3:21 pm

I have found that during printing and page break preview, it resets or ignores manual page breaks.
I have found that the following code will make Excel calculate the page breaks and then override the ones you want.
Code: Select all  Expand view
FUNCTION MAIN()
   LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
   LOCAL oSheet
   oExcel:WorkBooks:Add()
   oSheet = oExcel:ActiveSheet
   oExcel:ActiveWindow:View := 2
  // View = 2 sets excel to page break preview mode.
   oSheet:ResetAllPageBreaks()
   nTotalBreaks := oSheet:HPageBreaks:Count()
   for nCounter := 1 to nTotalBreaks
      oPageBreak := oSheet:HPageBreaks[nCounter]                // This Works
      do case
         case nCounter = 1
            cCells := 'A'+alltrim(str(nMyFirstBreak))
         case nCounter = 2
            cCells := 'A'+alltrim(str(nMySecondBreak))
      endcase
      oPageBreak:location := oSheet:Range( cCells )
   next
return nil
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests

cron