in reply to Re: how to convert excel file to text file?
in thread how to convert excel file to text file?

hi
when i use perl, it doesn't save the info as text file, no text file appear and when i run it, if it doesn't work, the dos like screen just end the program by itself the path to the file i've check it a lot of times, and still it doesn't work
  • Comment on Re^2: how to convert excel file to text file?

Replies are listed 'Best First'.
Re^3: how to convert excel file to text file?
by GrandFather (Saint) on Mar 13, 2008 at 10:15 UTC

    You might like to modify the path in the following then see if it works as a sanity check:

    use strict; use warnings; use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft Excel'; my $path = 'C:\Delme~~'; my $Excel = Win32::OLE->new ("Excel.Application", sub { $_[0]->Quit }) or die Win32::OLE::LastError; $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Add (); my $Sheet = $Book->Worksheets ('Sheet1'); $Sheet->Range ('A1')->{Value} = "Hello World"; $Sheet->Range ('A2')->{Value} = "Hi World"; $Excel->{DisplayAlerts} = 0; # avoid being prompted $Sheet->SaveAs ({FileName => "$path\\test.txt", FileFormat => xlText +}) or die Win32::OLE::LastError; $Book->Close (); $Excel->Quit; open IN, '<', "test.txt"; print <IN>; close IN;

    Prints:

    Hello World Hi World

    Perl is environmentally friendly - it saves trees