Using Spreadsheet::XLSX, how do I copy formats from one worksheet to another?
-
28-05-2021 - |
题
I'm using Perl v5.12.3 on Mac OSX Lion. I'm using the latest version of the Spreadsheet::XLSX module. How do you copy existing worksheet row, column, and cell formats from one XLSX file to a new file? For cells, I'm currently trying
my $cell = $oldWorksheet -> {Cells} [$row] [$col];
...
$newWorksheet->write( $newWorksheetCurRow, $col, $val, $cell->{Format} )
But it isn't working. For example, the background colors aren't getting copied and I don't even think "{Format}" is a valid attribute of the cell.
解决方案
Spreadsheet::XLSX doesn't read cell formats so it isn't possible to copy a worksheet formatting like this.
As far as I know there isn't any Perl module, apart from Win32::OLE that reads formatting from an XLSX file.
I'm working on one but formatting support is several months away.
其他提示
If it's like SpreadSheet::WriteExcel/ParseExcel, then you have to do it all manually. That is, create a new format on the writer side, then copy in all the attributes of the format from the parsed side.