17 Dec 2019 13:36:52 UTC
- Distribution: Spreadsheet-GenerateXLSX
- Module version: 0.05
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (400 / 0 / 0)
- KwaliteeBus factor: 1
- 49.09% Coverage
- License: perl_5
- Perl: v5.8.0
- Activity24 month
- Download (12.41KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
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_xlsxwhich 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
Spreadsheet::Template - used to generate spreadsheets from "JSON files which describe the desired content and formatting". By default it generates XLSX format.
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.
Spreadsheet::WriteExcel - provides the same interface as
Excel::Writer::XLSX, but generates the XLS format.
Spreadsheet::WriteExcel::FromDB - converts a database table to an XLS format spreadsheet.
Spreadsheet::WriteExcel::FromDB::Query - converts a query to an XLS spreadsheet, as opposed to a table.
Spreadsheet::WriteExcel::Simple - provides a simpler OO interface for generating single-sheet XLS spreadsheets.
Spreadsheet::Write - another simplified OO interface, which can write CSV or XLS output, but not XLSX.
Spreadsheet::Wright - a fork of
Spreadsheet::Writewhich supports more output formats (CSV, XLS, HTML, XHTML, XML, ODS, and JSON), but doesn't (appear to) support XLSX.
Spreadsheet::DataToExcel - provides a simple OO interface for generating XLS spreadsheets, and provides some control over the generated format. But, as with most of the modules listed here, only XLS output is supported.
Spreadsheet::WriteExcel::Simple::Tabs - a very simple OO interface built on
Spreadsheet::WriteExcel. This one is close to the spirit of
Spreadsheet::GenerateXLSX, but only generates XLS.
* smarter auto-formatting of columns * more tests * better error handler
Neil Bowers <email@example.com>
This software is copyright (c) 2016 by Neil Bowers <firstname.lastname@example.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.
Module Install Instructions
To install Spreadsheet::GenerateXLSX, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Spreadsheet::GenerateXLSX
For more information on module installation, please visit the detailed CPAN module installation guide.