Today, I'm going to use Perl to read Excel and convert it into an HTML table.
Search online, read the package of Excel Spreadsheet::P arseexcel Better, powerful cpan, let me a command on the download installed it: cpan Spreadsheet::P arseexcel
#!/usr/bin/perl-w UseStrict; UseSpreadsheet::Parseexcel; UseSpreadsheet::P arseexcel::Fmtunicode;my $parser= Spreadsheet::P arseexcel->new ();my $file=$ARGV[0];my $formmater= Spreadsheet::P arseexcel::fmtunicode->new (Unicode_map ="CP936"); my $workbook=$parser->parse ($file,$formmater);if( !defined $workbook ) { die $parser->error (),". \ n";}Open my $html,">","table.html"Or die;Print $html "<table border=1 style=\ "white-space:nowrap\" >"; for my $worksheet($workbook-Worksheets ()) { my($row _min,$row _max) =$worksheet-Row_range (); my($col _min,$col _max) =$worksheet-Col_range (); for my $row($row _min..$row _max ) { Print $html "<tr>"; for my $col($col _min..$col _max ) { Print $html "<td>"; my $cell=$worksheet->get_cell ($row,$col ); Next unless $cell; Print $html $cell-value (); Print $html "</td>"; } Print $html "</tr>"; }}Print $html "</table>";Close $html;
Perl reads Excel and translates into HTML table