in reply to Re^2: XLS to CSV file with Text wrap
in thread XLS to CSV file with Text wrap

Your script appears to be working correctly for me. Try this test program

#!/usr/bin/perl use strict; use warnings; use Text::Wrap; use Text::CSV_XS; my $csv = Text::CSV_XS->new ( { binary => 1, eol => "\r\n", auto_diag => 1 }); open my $fh, ">", "wraptest.csv" or die "$!"; my @data = ( ['1a this is more than 20 characters', '', '1c and another one that is more than 20 characters'], ['2a this is more than 20 characters', '', '2c and another one that is more than 20 characters'], ); for my $row_index (0..1){ my @row; for my $col_index (0..2){ my $source_cell = $data[$row_index][$col_index]; my $value; if ($source_cell){ local $Text::Wrap::columns = 20; $value = wrap ("", "", $source_cell); } push @row , $value; } $csv->print ($fh, \@row); } close $fh;
poj

Replies are listed 'Best First'.
Re^4: XLS to CSV file with Text wrap
by kshitij (Sexton) on Sep 03, 2018 at 06:54 UTC
    Hi Poj ,

    Thanks for providing this code . I have tested it , it seems I was looking for the pre-formatted xls content into CSV but I think that is not possible. Now I am splitting my consolidated XLS into multiple smaller XLS based on the pattern match and would like to color the xls based on some keywords in the smaller XLS.

    I am facing one issue while doing this , I have already raised this issue( not able to print the range of lines from big XLS ) in response to Tux reply. </p?

    Thanks

    Kshitij