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
In reply to Saving Excel file in Tab delimeted text or .csv by steveb94553
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |