steveb94553 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks,
I am a new Perl user and am trying to save a Excel file as a tab delimeted text file. When I run the following script it creates a .csv or .txt file (depending on the output file name), but it is still in a binary format.
+ + #should save C:\\work\\perl_WinOle\\sym_text_testdoc.xls as # a text or csv formatted document. # creates a file with .txt or csv extension, but # document is not a tab or comma delimeted text file.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
use Win32; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; #$file = "C:\\work\\perl_WinOle\\test.csv"; $OutFile = "C:\\work\\perl_WinOle\\sym_text_testdoc.txt"; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $xl = Win32::OLE::Const->Load($Excel); $Excel->{'Visible'} = 1; # if you want to see what's going on my $Book = $Excel->Workbooks->Open( "C:\\work\\perl_WinOle\\sym_text_t +estdoc.xls" ); $Book->Activate(); $Book->SaveAs($OutFile); $Book->Close;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxx
I found this snippet of code that saves a Word document as a text file: $document->SaveAs($txt, wdFormatText);
I assume that Excel would be somthing like: $book->SaveAs($txt, excelFormatText); excelFormatText probably should be something different. Does anyone know how to save an Excel file as a text delimeted text file?
Sorry about the format of my message, my question I entered does have spaces and lines for clarity, don't know why they don't exist in the examle posted message
Thanks, Steveb94553
20080601 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Saving Excel file in Tab delimeted text or .csv
by graff (Chancellor) on May 30, 2008 at 00:52 UTC | |
|
Re: Saving Excel file in Tab delimeted text or .csv
by NetWallah (Canon) on May 29, 2008 at 23:51 UTC | |
by steveb94553 (Initiate) on May 30, 2008 at 17:28 UTC | |
by NetWallah (Canon) on May 30, 2008 at 20:48 UTC | |
|
Re: Saving Excel file in Tab delimeted text or .csv
by Tux (Canon) on May 30, 2008 at 07:09 UTC | |
|
Re: Saving Excel file in Tab delimeted text or .csv
by steveb94553 (Initiate) on May 30, 2008 at 17:33 UTC |