dry_riser_inlet has asked for the wisdom of the Perl Monks concerning the following question:

I am happily parsing and writing Excel data from one workbook to another. However, I cannot find a way of copying the format of the cell in the source and applying it to the target. Is there a snappy way of reading the format of the source cell, storing it, and then applying it to the target cell? Apologies in advance for breaking many posting rules, this is my first go!

Replies are listed 'Best First'.
Re: Preserving xls formats with Perl
by hdb (Monsignor) on Aug 27, 2013 at 09:58 UTC

    It should be easy using Win32::OLE. Just search on PerlMonks for its usage.

      Ah, I forgot to mention I am working in linux environments - I didn't think Win32::OLE was possible? Perhaps with wine but not exactly easy?

Re: Preserving xls formats with Perl
by MidLifeXis (Monsignor) on Aug 27, 2013 at 13:18 UTC

    See the Spreadsheet and Excel namespaces on cpan. You can get most, if not all, format information from XLS and XLSX files. Since it is not an MS product parsing an MS data structure, there may be some things it does not do quite right, but in my usage, I have found them to be pretty good.

    I am using Spreadsheet::Read at the moment as a top-level layer for a spreadsheet reading on a project, and am starting to look at Spreadsheet::Wright as a top-level layer for spreadsheet writing. Formatting is available in both.

    --MidLifeXis