FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel Question
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel Question
Posted: Sun Feb 25, 2007 02:41 PM

Hi Everybody,

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

Thanks,

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Excel Question
Posted: Sun Feb 25, 2007 03:31 PM
This is a working sample:

#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
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel Question
Posted: Sun Feb 25, 2007 03: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):


http://nerds-central.blogspot.com/2007_ ... chive.html
" rel="noopener">
http://nerds-central.blogspot.com/2007_ ... chive.html



Jeff
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Excel Question
Posted: Sun Feb 25, 2007 03:50 PM
Jeff Barnes wrote:What does the xlPageBreakNone do?


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

EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel Question
Posted: Sun Feb 25, 2007 11:24 PM

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

Thanks Enrico.

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Excel Question
Posted: Mon Feb 26, 2007 03: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.
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

Continue the discussion