我使用Perl创建了我的Excel工作表 a.xls ,其中我有以下字段:
date name eid
13/jan/2010 asa 3175
当我下次编译时,如果日期将超过上一个日期,那么它必须像智慧一样更新:
date name eid
13/jan/2010 asa 3175
14/jan/2010 stone 3180
如果日期将是上一行日期,因为上一行日期为14/jan/2010
且当前日期也为14/jan/2010
,则它不应插入任何应该仅更新上一条记录的行。
答案 0 :(得分:5)
参见Spreadsheet::ParseExcel::SaveParser documentation中的示例。据我了解,AddCell方法可以替换现有的单元格或添加新的。
答案 1 :(得分:0)
答案 2 :(得分:0)
use Win32::OLE::Const 'Microsoft Excel';
$Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{DisplayAlerts}=0;
my $workbookpath = "D:\\temp.xlsx";
my $workbook = $Excel->Workbooks->Open($workbookpath);
# lets think if you created multiple sheets in an workbook, you can refer each workbook by name(Ex: sheet1 here)
my $sheet = $workbook->WorkSheets("sheet1");
#Insert row in a particular row value
$sheet->Cells(8,1)->EntireRow->Insert;
#save and close workbook, its a best practise when you are doing any excel operation
$workbook->Save;
$workbook->Close();