1
내 펄 스크립트는.xls 파일을 .csv 파일로 변환 하시겠습니까? .XLS 변환
use Spreadsheet::ParseExcel;
my $xlsparser = Spreadsheet::ParseExcel->new();
my $xlsbook = $xlsparser->parse('/home/Admin/Downloads/abc.xls');
my $xls = $xlsbook->worksheet(0);
my ($row_first, $row_last) = $xls->row_range();
my ($col_first, $col_last) = $xls->col_range();
my $csv = '/home/Admin/Downloads/ram.csv';
for my $row ($row_first .. $row_last) { # Step through each row
for my $col ($col_first .. $col_last) { # Step through each column
my $cell = $xls->get_cell($row, $col); # Get the current cell
next unless $cell;
$csv .= $cell->unformatted(); # Get the cell's raw data -- no border
# colors or anything like that
if ($col == $col_last) {
$csv .= "\n";
} else {
$csv .= ",";
}
}
}
open(my$FH ,'>',"$csv") or die "oops!";
while (my$line = <$xlsbook>){
print $FH $line;
}
아차, .csv로합니다! csv.pl 줄 23.
투척 오류. 내 코드에서 무엇이 잘못 되었습니까? 내 코드에서 오류를 찾으십시오. 미리 감사드립니다.
$의 CSV는 처음에 경로를 가리키는,
감사합니다 :
당신은 오타가 있습니다. 그렇다면 변수에 데이터를 추가하는 이유는 무엇입니까? open (my $ FH, '>', "$ csv")에서 파일을 열거 나 죽을 때 "oops!"; 이름이나 내용이 들어 있습니까? – Raghuram
콘텐츠 만 포함 – Ram
이 질문은 [이전 질문] (http://stackoverflow.com/q/21771708/725418)과 동일하면 (여는 것처럼 보이기 때문에) 새로운 질문. 귀하의 질문 중 하나가 그렇지 않으면 중복으로 보류 될 수 있습니다. – TLP