Hi Everybody,
Does anyone know how to force a "Page Break" in Excel via FW ?
Thanks,
Jeff
Excel Question
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Excel Question
This is a working sample:
EMG
Code: Select all
#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
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
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 ... hive.html
Jeff
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 ... hive.html
Jeff
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
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.
I have found that the following code will make Excel calculate the page breaks and then override the ones you want.
Code: Select all
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