Excel works with xHarbour, not Harbour

Excel works with xHarbour, not Harbour

Postby TimStone » Mon Jun 18, 2012 6:27 pm

The following function works with xHarbour ( .com ) / xCC / FWH 12.04.

It returns the message that Excel is not available when using Harbour / MSVC 2010 / FWH 12.04

Code: Select all  Expand view


FUNCTION ARToXls( aCodes, cTitle )
    *-----------------
    LOCAL oExcel, oAS
    LOCAL nRow, nCol, aStruct, i
    LOCAL nACnt := LEN( aCodes )
    nRow := nCol := nCtr := 0

    // Create the object
    oExcel := CreateObject( "Excel.Application" )

    IF Ole2TxtError() != "S_OK"
        ALERT ( "ERROR! Excel not available." )
        RETURN
    ENDIF

    oExcel:WorkBooks:Add( )
    oAS := oExcel:ActiveSheet( )

    oAS:Cells:Font:Name := "MS Sans Serif"
    oAS:Cells:Font:Size := 10

    oAS:Cells( 1, 1 ):Value :=  "Company             "
    oAS:Cells( 1, 2 ):Value :=  "Current   "
    oAS:Cells( 1, 3 ):Value :=  "Begin Bal."
    oAS:Cells( 1, 4 ):Value :=  "January   "
    oAS:Cells( 1, 5 ):Value :=  "February  "
    oAS:Cells( 1, 6 ):Value :=  "March     "
    oAS:Cells( 1, 7 ):Value :=  "April     "
    oAS:Cells( 1, 8 ):Value :=  "May       "
    oAS:Cells( 1, 9 ):Value :=  "June      "
    oAS:Cells( 1, 10):Value :=  "July      "
    oAS:Cells( 1, 11 ):Value := "August    "
    oAS:Cells( 1, 12 ):Value := "September "
    oAS:Cells( 1, 13 ):Value := "October   "
    oAS:Cells( 1, 14 ):Value := "November  "
    oAS:Cells( 1, 15 ):Value := "December  "

    FOR nRow := 1 TO nACnt
        oAS:Cells( nRow+1, 1 ):Value := aCodes[nRow][1]
        FOR i := 2 TO 15
            oAS:Cells( nRow+1, i ):Value := STR( aCodes[nRow][i], 12, 2 )
        NEXT
    NEXT

   FOR i = 1 to nACnt
      oAS:Columns( i ):AutoFit()
   NEXT

    oExcel:Visible := .T.
    oExcel:ActiveWorkbook:SaveAs( cTitle )
    oExcel:ActiveWindow:Close()
    oExcel:Quit()
    MsgInfo( cTitle + " has been created in your document folder" )
RETURN

 


I have had other problems with Active X operations using Harbour 3.0 and FWH 12.

Any thoughts on this problem ?

Thanks.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Excel works with xHarbour, not Harbour

Postby Antonio Linares » Tue Jun 19, 2012 3:12 pm

Tim,

It seems as Ole2TxtError() is not returning the right value.

If you comment out this code, then your example is working fine:

Code: Select all  Expand view
   
   /*
   IF Ole2TxtError() != "S_OK"
        ALERT ( "ERROR! Excel not available." )
        RETURN
   ENDIF
   */

 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Excel works with xHarbour, not Harbour

Postby TimStone » Tue Jun 19, 2012 3:17 pm

Thank you ... another difference between harbour and xharbour ...
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Excel works with xHarbour, not Harbour

Postby nageswaragunupudi » Mon Jun 25, 2012 12:12 pm

May I suggest using Fivewin function ExcelObj() to create excel object?

oExcel := ExcelObj()
if oExcel == nil
// excel not installed or could not be started
else
// proceed using oExcel
endif

This function is working well with xHarbour and Harbour ( bcc 582 ) and with xhb ( commerical )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel works with xHarbour, not Harbour

Postby TimStone » Mon Jun 25, 2012 5:46 pm

Thank you. ExcelObj( ) resolves the problem and works fine with xHarbour ( .com ) and Harbour/MSVC 2010.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests