converting an Excel (xls) file to a comma separated (csv) file without the GUI

前端 未结 13 1811
走了就别回头了
走了就别回头了 2020-12-01 05:29

Is there a simple way to translate an XLS to a CSV formatted file without starting the Excel windowed application?

I need to process some Excel XLS workbooks with sc

13条回答
  •  一向
    一向 (楼主)
    2020-12-01 06:23

    my solution:

    use Spreadsheet::BasicRead;
    
    my $xls = 'file.xls';   
    my $csv = 'file.csv';
    
       my $ss = new Spreadsheet::BasicRead($xls) or die "Could not open '$xls': $!";
       my $name = '';
       my $row = 0;
    
       open(FILE, ">$csv") or die "Could not open : $!\n";
          flock(FILE, 2) or die "Could not lock file\n"; 
    
            while (my $data = $ss->getNextRow()){
                $row++;
                $name = join(';',@$data);         
                print FILE $name."\n" if ($name ne "");
            }
    
          flock(FILE, 8); 
       close FILE; 
    

提交回复
热议问题