in reply to Excel > Data > Text to Columns (Win32::OLE)
I'm not absolutely clear what it is you want. There is a "Text to Columns" command in Excel, which may be what you are talking about. Anything that is available from the face of the spreadsheet is available from Win32::OLE. The classic advice is to record an Excel macro and translate that to Perl, but be warned that recorded macros are usually very bad VBA, and transliterating that without understanding it will lead to bad Perl. Is the following what you want?
use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; for my $nSht (2..$wb->Sheets->{Count}) { $wb->Sheets(2)->Delete; } my $sht = $wb->Sheets(1); $sht->Cells(1, 1)->{Value}="a b"; $sht->Cells(2, 1)->{Value}="a c"; $sht->Cells(3, 1)->{Value}="ab c"; $sht->Range("A1:A3")->TextToColumns({ Destination => $sht->Range("A1"), Space => 1, });
Regards,
John Davies
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Excel > Data > Text to Columns (Win32::OLE)
by Bascule (Initiate) on Apr 29, 2014 at 14:18 UTC | |
by davies (Monsignor) on Apr 29, 2014 at 14:39 UTC | |
by Bascule (Initiate) on Apr 29, 2014 at 15:01 UTC | |
by davies (Monsignor) on Apr 29, 2014 at 15:24 UTC |