++ed by:

1 PAUSE user

Neil Bowers


Spreadsheet::GenerateXLSX - function to generate XLSX spreadsheet from array ref(s)


 use Spreadsheet::GenerateXLSX qw/ generate_xlsx /;

 my @data = (
             ['Heading 1', 'Heading 2', 'Heading 2'],
             ['blah',      'blah',      'blah'],
             ['blah',      'blah',      'blah'],
 generate_xlsx('example.xlsx', \@data);


This module provides a function generate_xlsx which takes an array of Perl data and generates a simple Excel spreadsheet in the XLSX format. The generated sheets have the first row frozen, and auto filters enabled for every column.

Each sheet in the spreadsheet is generated from an array of rows, where each row is an arrayref. The first row is treated as a header row. Here's an example:

 my @sheet1 = (
    ['Pokemon',  'Type',      'Number'],
    ['Pikachu',  'Electric',  25],
    ['Vulpix',   'Fire',      37],
    ['Ditto',    'Normal',    132],

The generated spreadsheet can have any numbers of sheets:

 generate_xslx('pokemon.xlsx', \@sheet1, \@sheet2);

If you just pass arrayrefs, the sheets will be named Sheet1, Sheet2, etc. You can also pass the name of the sheet:

 generate_xslx('pokemon.xlsx', 'All Pokemon' => \@sheet1, 'Hit List' => \@sheet2);


The following modules can all generate the XLSX format. I also wrote a blog post which gives more details on some of these.

    Excel::Writer::XLSX - the underlying module used to generate the spreadsheet. Gives you full control over the spreadsheet generated, but as a result has a much more complex interface.

    Spreadsheet::WriteExcel::Styler - helps with formatting of cells when using Excel::Writer::XLSX or Spreadsheet::WriteExcel.

    Spreadsheet::Template - used to generate spreadsheets from "JSON files which describe the desired content and formatting". By default it generates XLSX format.

    Data::Table::Excel - converts between Data::Table objects and XLS or XLSX format spreadsheets.

    XLS::Simple - provides a simple interface for both reading and writing spreadsheets. Minimal documentation, and what there is is written in Japanese. The function for creating a spreadsheet is called `write_xls()`, but it generates the XLSX format.

The following modules only generate Microsoft's earlier xls binary format.


 * smarter auto-formatting of columns
 * more tests
 * better error handler




Neil Bowers <neilb@cpan.org>


This software is copyright (c) 2016 by Neil Bowers <neilb@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.