Hi Tux ,

Thanks for providing the solution. I have tried it out but the generated CSV file is not getting generated properly. It is splitting most of the content in the newlines in the CSV file and coming in a single column .

Please find my script .
#!/usr/bin/perl -w #use Text::CSV_XS; use strict; use warnings; use lib '/home/users/kulshrk/perl_module/lib64/perl5'; use Spreadsheet::ParseExcel; use Text::Wrap; use Text::CSV_XS; #use Text::CSV_XS qw( csv ); my $csv = Text::CSV_XS->new ({ binary => 1, eol => "\r\n", auto_diag = +> 1 }); open my $fh, ">", "Project_status_tracking_DFT.csv" or die "Project_st +atus_tracking_DFT.csv: $!"; my $sourcename = shift @ARGV or die "invocation: $0 <source file>\n"; my $source_excel = new Spreadsheet::ParseExcel; my $source_book = $source_excel->Parse($sourcename) or die "Could not +open source Excel file $sourcename: $!"; my $storage_book; #my $sheet = []; foreach my $source_sheet_number (0 .. $source_book->{SheetCount}-1) { # my $source_sheet = $source_book->{Worksheet}[$source_sheet_number]; print "--------- SHEET:", $source_sheet->{Name}, "\n"; next unless defined $source_sheet->{MaxRow}; next unless $source_sheet->{MinRow} <= $source_sheet->{MaxRow}; next unless defined $source_sheet->{MaxCol}; next unless $source_sheet->{MinCol} <= $source_sheet->{MaxCol}; # my $sheet = []; foreach my $row_index ($source_sheet->{MinRow} .. $source_sheet->{Max +Row}) { my @row; foreach my $col_index ($source_sheet->{MinCol} .. $source_sheet->{Ma +xCol}) { my $source_cell = $source_sheet->{Cells}[$row_index][$col_index]; my $value; if ($source_cell) { local $Text::Wrap::columns = 20; $value = wrap ("", "", $source_cell->Value); } push @row , $value; } $csv->print ($fh, \@row); } } close $fh;

Could you suggest something here ? I played with local $Text::Wrap::columns by changing the width but still issue is there .

Thanks Kshitij

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.