in reply to Creating Excel Spreadsheet from text data file

Hi,

There was a great article on Spreadsheet::WriteExcel in this month's TPJ by the author.

This looks like a standard CSV file, so you could have opened it up straight into excel by double-clicking the icon(if it has a csv extension). But hey, Perl is fun and learning new new things is great so why not use it!

The Win32::OLE module is surprisingly easy to use once you have braved it once or twice. I wrote a script the other day that uses OLE to interface with an ASP dll. OLE really opens things up (if you are on a Win32 system {grin})

BTW, there is some documentation with Excel examples in the ActiveState HTML docs.
  • Comment on Re: Creating Excel Spreadsheet from text data file

Replies are listed 'Best First'.
RE: Re: Creating Excel Spreadsheet from text data file
by zzspectrez (Hermit) on Nov 06, 2000 at 22:34 UTC

    I'll have to check out the article in TPJ. I understand that excel can open CSV files. You only have to tell it what the delimiters are and select which fields to import. However, this was an oppurtunity for me to write a usefull program that did something other then print "Hello World\n";, if you know what I mean! I especially find it hard to use perl for windows tasks.

    This is really one of my first attempts at using perl to parse a file and do something usefull with the data. I'm looking for suggestions on coding style and general improvements on my code.I'm still learning how to properly use regexes and not sure if Im doing things the best way.

    As far as the Win32::OLE module, I have looked at the Activestate documents and seen that faq that show how to control Excel. The documentation still leaves me not exactly sure what OLE is and how to use it properly. For example, how do you know which applications can be controlled using OLE and what methods are available through this OLE control? The documentation gives reference on how to find information to controll Microsoft office apps and Lotus notes but falls silenty on all others.

    I looked at your script. Not sure what program needs to be installed for access to the OLE, but it does not work on my system.

    Thanks for your response!

    zzspectrez

      I agree with you. It's great to try your hand at things to find other ways of doing everyday tasks. Perl is perfect for this sort of thing

      Have a look at this node for information on the OLE browser. I posted this question because I had a vague idea about what OLE did but didn't know how the browser could help me. In the end, I used I couldn't have written the above code without it. For some reason the OLE browser didn't work on my PC - it turns out that I needed to make a change to the registry. Thanks Zoogie!

      My understanding(from my imagination) of OLE is that most (not all) Win32 apps provide sort of external hooks. You can create an OLE object (it becomes an application server) with one of those applications and access those hooks from your Perl script. So in theory you can do whatever the application itself does (assuming that the author provided all the hooks.)

      I have since written a Win32 script that uses OLE to "access" an Access database and pull out records etc.

      While it's all quite fun, it means that your code isn't very portable though - you can only run it on Win32 (and maybe soon Mac?). So if there is a module out there that does the job I would stick to that.

      UPDATE: I think maybe I put too many '()' in this reply. Maybe it's unreadable. Sorry.