我有一张 Excel 表,我需要清空一些单元格
到目前为止,这是它的样子:
我打开工作表,检查 M 列中的单元格是否为空。我将这些单元格添加到我的数组错误中,然后我想将所有这些单元格设为黑色并保存文件(此步骤不起作用),因为该文件需要成为另一个程序的输入/谢谢!
$infile = $ARGV[0];
$columns = ReadData($infile) or die "cannot open excel table\n\n";
print "xls sheet contains $columns->[1]{maxrow} rows\n";
my $xlsstartrow;
if ( getExcel( A . 1 ) ne "text" ) {
$xlsstartrow = 2;
}
else
{
$xlsstartrow = 4;
}
check_templates();
print "done";
sub check_templates {
for ( $row = $xlsstartrow ; $row < ( $columns->[1]{maxrow} + 1 ) ; $row++ ) {
if (getExcel(M . $row) ne "" ){
$cell = "M" . $row ;
push(@mistakes,$cell);
}
}
rewritesheet(@mistakes);
}
sub rewritesheet {
my $FileName = $infile;
my $parser = Spreadsheet::ParseExcel::SaveParser->new();
my $template = $parser->Parse($FileName);
my $worksheet = $template->worksheet(0);
my $row = 0;
my $col = 0;
# Get the format from the cell
my $format = $template->{Worksheet}[$sheet]
->{Cells}[$row][$col]
->{FormatNo};
foreach (@mistakes){
$worksheet->AddCell( $_, "" );
}
$template->SaveAs($infile2);`