Search code examples
perlspreadsheetxlsxformats

Using Spreadsheet::XLSX, how do I copy formats from one worksheet to another?


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.


Solution

  • 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.