Sign in to follow this  
Followers 0
autosc

Excel Grid Object

9 posts in this topic

CODE
$oExcel = ObjCreate("OWC11.spreadsheet")

and then using the folowing to put values in cells :

CODE
.cells("9","3").value = "5000"

puts in range C9

what is the coorect syntax to get Range "C9 " to autoit variable $myvar

Share this post


Link to post
Share on other sites



$myvar = $oExcel.Range("C9").Value

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

thanks ! you saved my day !

is there a way to load excel sheets partillay or fully to the Grid ? it seems hard ....some hints ?

probably wit examples ??

Share this post


Link to post
Share on other sites

The OWC spreadsheet is part of Office Web Controls and as such there is no straightforward way to load Excel workbooks into it. It's designed for embedded web applications and therefore isn't a full-featured workbook container object. There is, however, an option to export the spreadsheet to an Excel workbook.

The OWC spreadsheet can be told to import data from a web page, a text file, or an XML file. It can also be told to connect to an external data source, i.e. a SQL database server. Barring these options, you're limited to copy & paste.

If the spreadsheet data you're working on doesn't need to be embedded into a custom GUI, you might consider using the full Excel COM set. With it you can do basically anything Excel related. You can even hide Excel operations from the user and perform spreadsheet operations in the background.

$oExcel = ObjCreate("Excel.Application") ; to use the full-fledged Excel object

At the link in my signature you'll find a collection of functions that will allow you to perform numerous operations with Excel workbooks/sheets without having to know Excel COM.

Good luck with your Excel endeavors!

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Share this post


Link to post
Share on other sites

@autosc

look at my "Excel Grid In AutoIT"

And download the OWC help Reference OWC Helpfile

This might give you some hints.

regards

ptrex

Locodarwin : what about if i have sheets called , sheet 1 , sheet2

how should be the syntax $myvar = $oExcel.Range("C9").Value ? I am lost here ...

Share this post


Link to post
Share on other sites

Right, so in that case there are a couple of ways to go about returning info from the proper sheet.

The first is to use the Sheets collection to directly address the proper sheet:

$myvar = $oExcel.Sheets(x).Range("C9").Value
oÝ÷ Ùh^­ìb±©îêârö¥¹ê+jËkx'jg¢«¨µë+zÞ±éíx-ë!yëgºfÞ®v¦{*.Á©í¶që,N¬yÊ'w²ËhºÇ­ä¡yëlreyËb¢{h©¶¬ç­Ê°j{ZrدzÇ¥yË^u·¢·«zÛ«)ණjxjëh×6
$oExcel.Sheets(x).Select
$myvar = $oExcel.Range("C9").Value

There are other ways as well. It's a matter of preference or effect as to which procedure you'll use. In my UDF collection, for example, the functions perform actions on the active sheet just to keep the logic flow simplified.

Do a search for the file OWCDSS11.CHM on your system, open it, and browse through the "Programming Information" subheading for more information on how to use COM to interact with this component.

Also consider using ptrex's "Excel Grid in AutoIt" solution, linked in his signature. His example demonstrates quite a few important techniques for using the grid.

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

Right, so in that case there are a couple of ways to go about returning info from the proper sheet.

The first is to use the Sheets collection to directly address the proper sheet:

$myvar = $oExcel.Sheets(x).Range("C9").Value
oÝ÷ Ùh^­ìb±©îêârö¥¹ê+jËkx'jg¢«¨µë+zÞ±éíx-ë!yëgºfÞ®v¦{*.Á©í¶që,N¬yÊ'w²ËhºÇ­ä¡yëlreyËb¢{h©¶¬ç­Ê°j{ZrدzÇ¥yË^u·¢·«zÛ«)ණjxjëh×6
$oExcel.Sheets(x).Select
$myvar = $oExcel.Range("C9").Value

There are other ways as well. It's a matter of preference or effect as to which procedure you'll use. In my UDF collection, for example, the functions perform actions on the active sheet just to keep the logic flow simplified.

Do a search for the file OWCDSS11.CHM on your system, open it, and browse through the "Programming Information" subheading for more information on how to use COM to interact with this component.

Also consider using ptrex's "Excel Grid in AutoIt" solution, linked in his signature. His example demonstrates quite a few important techniques for using the grid.

-S

Locadarwin ;

Not worked ! but your suggestions to check OWCDSS11.chm helped a lot .

the solution was according to the refeerens >>> Spreadsheet1.Worksheets("Sheet2").Activate << and worked .

But your udf is promising . I just run the examples . I wanted to use the grid in Gui . otherwise , your udf should be the

best alternative , I guess .

I tried to load Xml sheet and working ok . Thank you for your Guidance .

PTREX :

I wested a lot of time without exploring your grid . It was nice . But was a good idea if you add more examples , for example

displaying a graph , and other methods . The link you showed me to MsdN , gave me a push in my learning. Thank you !

Share this post


Link to post
Share on other sites

That's yet another way. It should still work as I stated, though - perhaps something is lost in the translation.

An example using your solution:

#include <GUIConstants.au3>

$oExcel = ObjCreate("OWC11.spreadsheet")
GuiCreate("Excel Object", 802, 590, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUI_ActiveX = GUICtrlCreateObj ($oExcel, 10, 10 , 780 , 550)

$oExcel.Worksheets("Sheet2").Activate
$oExcel.Range("C9").Value = "Dude!"

Sleep(5000)
Exit
oÝ÷ Ø    ÞÅ©©ë¬x(ê+(ëb¢{ºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ë]LÉÝÂÌÍÛÑ^Ù[HØÜX]J ][ÝÓÕÐÌLKÜXYÚY]  ][ÝÊBÝZPÜX]J    ][ÝÑ^Ù[ØXÝ ][ÝË
NLLKLK  ÌÍÕÔ×ÓÕTTQÒSÕÈ
È  ÌÍÕÔ×ÕTÒPH
È  ÌÍÕÔ×ÐÓTÒPSÔÊBÌÍÑÕRWÐXÝ]VHÕRPÝÜX]SØ
    ÌÍÛÑ^Ù[LL
Î
ML
BÌÍÛÑ^Ù[ÚY]Ê ][ÝÔÚY]][ÝÊKÙ[XÝÌÍÛÑ^Ù[[ÙJ ][ÝÐÎI][ÝÊK[YHH    ][ÝÑYIÌÌÎÉ][ÝÂÛY
L
B^]

Both of these work for me.

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0