Catalyst-Action-Serialize-SimpleExcel

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

            $authors_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');

            my @authors = map {
                [ @{$_}{qw/first_name middle_name last_name/} ]
            } $authors_rs->all;

            my $entity = {
                sheets => [
                    {
                        name => 'Books',
                        header => ['Author', 'Title'], # will be bold
                        rows => \@books,
                    },
                    {
                        name => 'Authors',
                        header => ['First Name', 'Middle Name', 'Last Name'],
                        rows => \@authors,
                    },
                ],
                # the part before .xls, which is automatically appended
                filename => 'myapp-books-'.strftime('%m-%d-%Y', localtime)

README  view on Meta::CPAN

    fields:

  name
    Optional. The name of the worksheet.

  rows
    Required. The array of arrays of rows.

  header
    Optional, an array for the first line of the sheet, which will be in
    bold.

  column_widths
    Optional, the widths in characters of the columns. Otherwise the widths
    are calculated automatically from the data and header.

    If you only have one sheet, you can put it in the top level hash.

AUTHOR
    Rafael Kitover, "<rkitover at cpan.org>"

lib/Catalyst/Action/Serialize/SimpleExcel.pm  view on Meta::CPAN

        $authors_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');

        my @authors = map {
            [ @{$_}{qw/first_name middle_name last_name/} ]
        } $authors_rs->all;

        my $entity = {
            sheets => [
                {
                    name => 'Books',
                    header => ['Author', 'Title'], # will be bold
                    rows => \@books,
                },
                {
                    name => 'Authors',
                    header => ['First Name', 'Middle Name', 'Last Name'],
                    rows => \@authors,
                },
            ],
            # the part before .xls, which is automatically appended
            filename => 'myapp-books-'.strftime('%m-%d-%Y', localtime)

lib/Catalyst/Action/Serialize/SimpleExcel.pm  view on Meta::CPAN

=head2 name

Optional. The name of the worksheet.

=head2 rows

Required. The array of arrays of rows.

=head2 header

Optional, an array for the first line of the sheet, which will be in bold.

=head2 column_widths

Optional, the widths in characters of the columns. Otherwise the widths are
calculated automatically from the data and header.

If you only have one sheet, you can put it in the top level hash.

=cut

lib/Catalyst/Action/Serialize/SimpleExcel.pm  view on Meta::CPAN


    $worksheet->keep_leading_zeros(1);

    my ($row, $col) = (0,0);

    my @auto_widths;

# Write Header
    if (exists $sheet->{header}) {
        my $header_format = $workbook->add_format;
        $header_format->set_bold;
        for my $header (@{ $sheet->{header} }) {
            $auto_widths[$col] = length $header
                if $auto_widths[$col] < length $header;

            $worksheet->write($row, $col++, $header, $header_format);
        }
        $row++;
        $col = 0;
    }



( run in 1.793 second using v1.01-cache-2.11-cpan-39bf76dae61 )