Home > Archive > AWK > July 2006 > tawk and excel automation
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
tawk and excel automation
|
|
|
| all
does anyone have a snippet of tawk code to open an excel sheet and
read/write to cells?
I could use some pointers on how to get going... if its possible.
thanks
rex
| |
| Andrew Poelstra 2006-07-11, 6:56 pm |
| On 2006-07-11, trexx <foo@foo.com> wrote:
> all
> does anyone have a snippet of tawk code to open an excel sheet and
> read/write to cells?
> I could use some pointers on how to get going... if its possible.
> thanks
> rex
>
What format is this? (.xls, .ods, etc)
--
Andrew Poelstra <http://www.wpsoftware.net/projects/>
To email me, use "apoelstra" at the above domain.
"You people hate mathematics." -- James Harris
| |
|
| "Andrew Poelstra" <apoelstra@localhost.localdomain> wrote in message
news:slrneb7fkb.ag.apoelstra@localhost.localdomain...
> On 2006-07-11, trexx <foo@foo.com> wrote:
>
> What format is this? (.xls, .ods, etc)
Currently I'm using microsoft's excel with .xls format extensively at the
office.
rex
| |
| Harlan Grove 2006-07-12, 6:56 pm |
| trexx wrote...
>does anyone have a snippet of tawk code to open an excel sheet and
>read/write to cells?
>I could use some pointers on how to get going... if its possible.
....
If tawk can create Windows OLE Automation objects, then create such an
object for the Excel.Application OLE class. Then use Excel object model
methods and properties to open .XLS files and do what you want.
If tawk can't create Windows OLE Automation objects, the closest you
could get would be either using tawk to create script files for other
languages that can manipulate Windows OLE Automation objects and use
system to call them or try to manipulate .XLS files as binary files (a
VERY, VERY BAD idea). There's a Perl module that can do this. Maybe you
could translate it to tawk.
| |
| Stephan Titard 2006-07-13, 7:57 am |
| trexx escribió:
> all
> does anyone have a snippet of tawk code to open an excel sheet and
> read/write to cells?
> I could use some pointers on how to get going... if its possible.
> thanks
> rex
>
>
an approach similar in spirit to Harlan's second paragraph
could be the following
- create a small server that handles excel calls
- drive it from awk via system (or use it as a coprocess if you have gawk)
now that small server would answer
few directives: OPEN ..., ADDCELL ..., CLOSE ... for ex.
* perl is certainly an option: I used Spreadsheet::WriteExcel which
works quite well even from a non-windows platform
* another possibility if you have java installed, is to use one library
from jakarta, and write the server in beanshell (easier and quite
in the spirit of cooperation between scripting languages)
you need to download the 2 jars: http://jakarta.apache.org and
http://beanshell.org
hth
--stephan
| |
| William James 2006-07-14, 6:56 pm |
| trexx wrote:
> "Andrew Poelstra" <apoelstra@localhost.localdomain> wrote in message
> news:slrneb7fkb.ag.apoelstra@localhost.localdomain...
> Currently I'm using microsoft's excel with .xls format extensively at the
> office.
> rex
You could use Ruby.
require 'win32ole'
excel = WIN32OLE.new( 'excel.application' )
excel.visible = true
workbook = excel.Workbooks.Add(1)
worksheet = workbook.Worksheets( 'Sheet1' )
excel.ole_get_methods.each{|x| p x}
puts excel.ole_method_help("Columns")
worksheet.Cells( 1, 1 )[ 'Value' ] = "Hello!"
(1..10).each {|row|
(1..10).each {|column|
worksheet.Cells( row, column )[ 'Value' ] = row * column
}
}
%w( Is a potato edible? ).each_with_index{|word,i|
worksheet.Cells( 20 - i, 5 + i ).value = word
worksheet.Cells( 20 - i, 5 + i ).Font['Bold'] = true
}
(5..8).each{|col| worksheet.Columns( col ).AutoFit }
worksheet.Range( "e17:h20" ).Select()
|
|
|
|
|