Catalyst-Action-Serialize-SimpleXLSX

 view release on metacpan or  search on metacpan

lib/Catalyst/Action/Serialize/SimpleXLSX.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/SimpleXLSX.pm  view on Meta::CPAN

  my $worksheet = $workbook->add_worksheet( $sheet->{name} ? $sheet->{name} : () );
  $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} } ) {
      if (defined $auto_widths[$col] && $auto_widths[$col] < length $header) {
        $auto_widths[$col] = length $header;
      }
      $worksheet->write( $row, $col++, $header, $header_format );
    }
    $row++;
    $col = 0;
  }



( run in 2.422 seconds using v1.01-cache-2.11-cpan-5dc5da66d9d )