in reply to Re^2: how to convert excel file to text file?
in thread how to convert excel file to text file?
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
|
|---|