If it's going to be a script that will be used by many people as a utility,
it may be worth while to automate it with OLE, but if it is a one shot deal,
or if you are the only one that will be running it, you'd probably be better
off saving the spreadsheet as a tab or comma delimited text file and parsing
that instead.  It would be both easier to write the code, and faster to run.

Open the spreadsheet and select the "Save As" from the file menu.  In the
Save As dialog set the "Save as type" to "Text (Tab delimited)(*.txt)".
Give it a file name and click "OK".

Then parse the text file like this

open(INFILE, "filename.txt");
while(INFILE) {
   chomp;
   ($dept,$number) = split(/\t/, $_);
   # other code as required
}


You can always add automation to it later by using OLE to open the
spreadsheet and execute the "Save As" command to create a temp file.  Then
you can parse the temp file.


wantor


> -----Original Message-----
> From: Scott K Purcell [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 05, 2000 7:21 AM
> To: Perl-Win32-Users Mailing List
> Subject: Excel File Help Please
> 
> 
> Hello,
> I was just handed an "excel" file, and was told to parse it. 
> I have never 
> used any of the Ole stuff, and I don't know if I should use 
> that, or just 
> treat it as a "flat file".? I am for the most part a web guy.
> 
> Anyway, the file looks like (eg of 4 lines out of about 1000 lines).
> dept   number   itemd1   itemd2    cost   special  etc   etc   etc
> 1      123567    text    text       2.99   3.01    
> 1      127889    text    text       number  number  etc etc etc
> 2      193425    text     text
> 2      16978     text
> 3      149080    text
> 
> Anyway, I only need to be concerned with the first two rows. 
> "Dept" and 
> "Number". And what they want is a text file for each dept, 
> and in it each 
> of the numbers in a list.
> 
> So if there are 30 departments, then I will have 30 text 
> files written to 
> disk with each of the numbers in them in a list.
> 
> Anyway, I hope that is enough info. So back to my main 
> question, what is 
> the "best" way to parse an excel file? Through Excel, or 
> treat it as a flat 
> file?
> 
> 
> Thanks
> Sorry such a long explanation, but this is a little out there 
> for me on a 
> Friday,
> Scott
> 
> ---
> You are currently subscribed to perl-win32-users as: 
> [EMAIL PROTECTED]
> To unsubscribe, forward this message to
>          [EMAIL PROTECTED]
> For non-automated Mailing List support, send email to  
>          [EMAIL PROTECTED]
> 

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to