excel tactivex

excel tactivex

Postby nageswaragunupudi » Sun Apr 08, 2007 9:00 am

Can anyone help me? How can this vbscript be writtein in xharbour + fwh with tactivex control of fwh?

Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: excel tactivex

Postby Enrico Maria Giordano » Sun Apr 08, 2007 9:57 am

This is an incomplete test. It shows the spreadsheet but I was not able to get or set ColumnHeadings property:

Code: Select all  Expand view  RUN
#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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » Sun Apr 08, 2007 1:37 pm

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

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

Postby Antonio Linares » Sun Apr 08, 2007 6:36 pm

You are missing this:

With .ActiveWindow

Here you have it working:
Code: Select all  Expand view  RUN
#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

Image
regards, saludos

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

Postby Enrico Maria Giordano » Sun Apr 08, 2007 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sun Apr 08, 2007 7:49 pm

Enrico,

What's your Office PROGID ?
regards, saludos

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

Postby Enrico Maria Giordano » Sun Apr 08, 2007 8:28 pm

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

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

Postby Antonio Linares » Sun Apr 08, 2007 8:48 pm

Enrico,

Yes, that may be fine.

Have you considered to upgrade to Office 2003 ?
regards, saludos

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

Postby Enrico Maria Giordano » Sun Apr 08, 2007 9:32 pm

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

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

Postby Antonio Linares » Sun Apr 08, 2007 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42121
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Sun Apr 08, 2007 9:46 pm

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

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

Postby Jeff Barnes » 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
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Sun Apr 08, 2007 10:10 pm

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

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

Postby Enrico Maria Giordano » Sun Apr 08, 2007 10:44 pm

Ok, this is how to set cells values. It should work on any OWC version:

Code: Select all  Expand view  RUN
#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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests

cron