Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accesssing Excel sheets through tcl? 1

Status
Not open for further replies.

notmeatleast

Programmer
May 25, 2004
8
FR
Hi,

I wish to read an excel sheet table from tcl version 8.3. Is it possible to do so. I've not worked very extensively in tcl though. It's an urgent requirement. If not in excel, then reading tables from .doc files? I would be heartly greateful to you all. Thanks in advance. :)

Adi

 
You can also follow thread287-602666 in this forum.

Bob Rashkin
rrashkin@csc.com
 
I have recently used csv files for data tables being read by a tcl program I wrote to create code from them automatically.
Some of it from the foreach loop:
set count [scan $line_body "%d, %d, %d, %d," w x y z ]
if {$count != 4} { break }
 
Thanks a lot. The links have been very helpful in making a excel file. But the topic is still not very clear to me.

There's this example:
----------------------------------------------------------
# Extract some cells from an Excel file
#
package require tcom

set app [::tcom::ref getobject [file nativename [file join [pwd] "test_tcom.xls"]]]
set ws [$app Worksheets]
set ws1 [$ws Item [expr 1]]

set cells [$ws1 Cells]

foreach row {1 2 3 4} {
foreach col {A B C} {
set cell [$cells Item $row $col]
puts "Row/column ($row/$col): [$cell Item]"
}
}
$app Close
----------------------------------------------------------

But when I run it the debugger gives me an error at the puts command, saying too few arguments for $cell. It doesn't execute [$cell Item] statement.

And i wasn't able to follow how to read as per modem7's intructions. Could you be please more elaborative.
 
Hi,
I went to the VB pages at MSDN, and got this feeling of replacing [$cell Item] with [$cell Value]. AND IT WORKED!. I do thank you. But just a little question. If I open a excel sheet through tcom, can I know how many rows and cloumns are existing in that excel sheet?

Thanks.
 
something like "activesheet.rows.count"?

Bob Rashkin
rrashkin@csc.com
 
Somehow I missed thie reply of yours. Yes. That's exactly what I need. Deoes it work? And how? I've already thaked you for the posts of yours though.
 
Somehow I missed this reply of yours. Yes. That's exactly what I need. Deoes it work? And how? I've already thaked you for the posts of yours though.
 
It's a VBA command so you have to send it through to $app. As I said, I never used it but I guess it would be something like: $app.activesheet.rows.count?

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top