Thread Spreadsheet::ParseExcel
(5 answers)
Opened by Gast at 2008-03-28 18:25
Probleme ist übertrieben.
Die Zellen mit Beistrich vermehren sich: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::Utility qw(xls2csv); use Text::CSV::Simple; my $file_xls = 'test.xls'; my $workbook = new Spreadsheet::WriteExcel($file_xls); die "Problems creating new Excel file: $!" unless defined $workbook; my $sheet = $workbook -> add_worksheet('Titel_1'); foreach my $col(0..2){ foreach my $row (0..2){ $sheet -> write($row, $col, 'Hi, Mrs'); } } $workbook -> close() or die "Error closing file: $!"; my $rotate = 0 ; my $coords = '0-A1:C3'; my $file_csv='test.csv'; open(File, ">$file_csv"); printf File xls2csv( $file_xls, $coords, $rotate); close(File); my $parser = Text::CSV::Simple->new; my @data = $parser->read_file($file_csv) or die "Problems reading file: $!"; my $file_neu_xls = 'test_neu.xls'; $workbook = new Spreadsheet::WriteExcel($file_neu_xls); die "Problems creating new Excel file: $!" unless defined $workbook; $sheet = $workbook -> add_worksheet('Titel_1'); my $col = 0; foreach my $ref (@data){ my $row = 0; foreach my $cell (@$ref){ $sheet -> write($row++, $col, $cell); } $col++; } $workbook -> close() or die "Error closing file: $!"; |