in reply to Re^3: Create CSV file from xlsx file
in thread Create CSV file from xlsx file
thank you ken.. those 2 lines really helped me a lot and now i am able to print those values. While creating it in the CSV file I am getting the 4 columns values in the single column.But i want each values in separate column?
use strict; use warnings; use diagnostics; use Spreadsheet::XLSX; use Spreadsheet::Read; use Text::CSV; my $excel = Spreadsheet::XLSX -> new ('Sample.xlsx',); my $csv = Text::CSV->new (); foreach my $sheet (@{$excel -> {Worksheet}}) { printf("Sheet: %s\n", $sheet->{Name}); my @worksheet = qw(sheet1 sheet2); my $maxrow = $sheet -> {MaxRow}; my $Minrow = 1; my @wanted_cols = (8, 9, 10, 20); $maxrow ||= $Minrow; open FH, ">new.csv" or die "new.csv: $!"; foreach my $row ($Minrow .. $maxrow) { foreach my $wanted_cols (@wanted_cols) { my $wanted_cells = $sheet->{Cells}[$row][$wan +ted_cols]; print FH ( $wanted_cells -> {Val} ); } print FH ("\n"); } close FH or die "new.csv: $!"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Create CSV file from xlsx file
by Tux (Canon) on Oct 28, 2013 at 09:17 UTC | |
by viji234 (Initiate) on Oct 28, 2013 at 10:48 UTC | |
by Tux (Canon) on Oct 28, 2013 at 12:07 UTC | |
by viji234 (Initiate) on Oct 28, 2013 at 12:27 UTC |
In Section
Seekers of Perl Wisdom