in reply to XLS to CSV file with Text wrap
When writing your CSV, you should use Text::CSV_XS instead of using print to write the data.
My approach to writing a CSV file from data would be to convert the Excel data to an array of arrays and then write that out through the csv function of Text::CSV_XS. See the reply by Tux for better code, but this is the basic idea:
... my $sheet = []; foreach my $row_index ($source_sheet->row_range) { my $row = []; foreach my $col_index ($source_sheet->col_range) { my $source_cell = $source_sheet->{Cells}[$row_index][$col_index]; if ($source_cell) { #print "( $row_index , $col_index ) =>", $source_cell->Value, ","; push @$row, $source_cell->Value; } } push @$sheet, $row; } csv( in => $sheet, out => 'file.csv' );
See the documentation of Text::CSV_XS on the csv function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XLS to CSV file with Text wrap
by kshitij (Sexton) on Sep 01, 2018 at 04:27 UTC | |
by Corion (Patriarch) on Sep 01, 2018 at 06:32 UTC | |
by kshitij (Sexton) on Sep 01, 2018 at 10:33 UTC | |
by poj (Abbot) on Sep 01, 2018 at 11:11 UTC | |
by kshitij (Sexton) on Sep 01, 2018 at 14:33 UTC |