FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour excel tactivex
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
excel tactivex
Posted: Sun Apr 08, 2007 09:00 AM
Can anyone help me? How can this vbscript be writtein in xharbour + fwh with tactivex control of fwh?

Dim Spread As OWC11.Spreadsheet

Dim stYears(0 To 2) As String
Dim iCounter As Integer

stYears(0) = "1996"
stYears(1) = "1997"
stYears(2) = "1998"

Set Spread = Me.Spreadsheet1

With Spread

    .Height = 3540

    .Width = 4695

    With .ActiveWindow

    'Set the caption of the actual columnheadings.

        .ColumnHeadings(1).Caption = "Country "

        .ColumnHeadings(2).Caption = "Freight "

        .ColumnHeadings(3).Caption = "Shipments "

        'Set the caption of the actual rowheadings.

        For iCounter = 0 To 2

            .RowHeadings(iCounter + 1).Caption = stYears(iCounter)

            .RowHeadings(iCounter + 4).Caption = stYears(iCounter)

        Next iCounter

        'Limit the viewable part of the worksheet.

        .ViewableRange = "A1 : D6"

    End With

End With

Set Spread = Nothing
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: excel tactivex
Posted: Sun Apr 08, 2007 09:57 AM
This is an incomplete test. It shows the spreadsheet but I was not able to get or set ColumnHeadings property:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oOwc, oColumnHeadings

    DEFINE WINDOW oWnd

    @ 0, 0 ACTIVEX oOwc;
           PROGID "OWC.Spreadsheet"

    oColumnHeadings = oOwc:GetProp( "ColumnHeadings" )

    // This is NIL and I don't know why:

//    ? oColumnHeadings

    oWnd:oClient = oOwc

    ACTIVATE WINDOW oWnd

    RETURN NIL


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
excel tactivex
Posted: Sun Apr 08, 2007 01:37 PM

yes. i could not find out how to get this working.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
excel tactivex
Posted: Sun Apr 08, 2007 06:36 PM
You are missing this:

With .ActiveWindow

Here you have it working:
#include "Fivewin.ch" 

FUNCTION MAIN() 

   LOCAL oWnd, oOwc, oActiveWindow, nCounter

   DEFINE WINDOW oWnd 

   @ 0, 0 ACTIVEX oOwc; 
           PROGID "OWC11.Spreadsheet" 

   oActiveWindow = oOwc:GetProp( "ActiveWindow" )

   OleSetProperty( oActiveWindow, "ColumnHeadings", 1, "Country" )
   OleSetProperty( oActiveWindow, "ColumnHeadings", 2, "Freight" )
   OleSetProperty( oActiveWindow, "ColumnHeadings", 3, "Shipments" )

   for nCounter = 0 To 5 
      OleSetProperty( oActiveWindow, "RowHeadings", nCounter + 1, Str( 2000 + nCounter ) )    
   next   

   OleSetProperty( oActiveWindow, "ViewableRange", "A1:D6" )

   oWnd:oClient = oOwc
    
   ACTIVATE WINDOW oWnd

RETURN NIL

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 07:35 PM
Antonio Linares wrote:You are missing this:

With .ActiveWindow


I already tried it and unfortunately it doesn't work for me (Office 2000). :-)

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
excel tactivex
Posted: Sun Apr 08, 2007 07:49 PM

Enrico,

What's your Office PROGID ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 08:28 PM

Where can I find it? I'm using "OWC.Spreadsheet" for Office Web Component.

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
excel tactivex
Posted: Sun Apr 08, 2007 08:48 PM

Enrico,

Yes, that may be fine.

Have you considered to upgrade to Office 2003 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 09:32 PM

I don't really need of Office. And I can't write code that only works on Office 2003.

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
excel tactivex
Posted: Sun Apr 08, 2007 09:39 PM

Enrico,

> And I can't write code that only works on Office 2003.

I agree with you :-)

Anyhow, the sample is working fine

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 09:46 PM

Yes. I'm currently searching a way to manage OWC cells in a Office-version-independent way.

EMG

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
excel tactivex
Posted: Sun Apr 08, 2007 10:01 PM

Enrico,

You might want to try "Open Office" ( http://www.openoffice.org/ )

It is said to be compatible with MS-Office and it is FREE.

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 10:10 PM

Sorry, I can't force my clients to migrate to OpenOffice.

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
excel tactivex
Posted: Sun Apr 08, 2007 10:44 PM
Ok, this is how to set cells values. It should work on any OWC version:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oOwc, hSheet, hActiveWindow

    DEFINE WINDOW oWnd

    @ 0, 0 ACTIVEX oOwc;
           PROGID "OWC.Spreadsheet"

    hSheet = oOwc:GetProp( "ActiveSheet" )

    OLESETPROPERTY( hSheet, "Cells", 1, 1, "This is a test" )

    oWnd:oClient = oOwc

    ACTIVATE WINDOW oWnd

    RETURN NIL


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
excel tactivex
Posted: Sun Apr 08, 2007 10:46 PM

Thank you Mr. Antonio. Now I am able to do this and other similar examples.

Still I have one general problem. How do I know what is the office version of on the target machine and decide whether to use owc or owc11 ? What should I use for office 2007.

With office2003 if i use owc, I am getting GPF. I am wondering how can i make the software that can recongnise the office version and work accordingly

Regards



G. N. Rao.

Hyderabad, India