foreach my $row (@{ $row_set }) {
$inner_idx++;
+ my $output_columns = [ ];
+ my $skip_next = 0;
foreach my $col_name (@visible_columns) {
+ if ($skip_next) {
+ $skip_next--;
+ next;
+ }
+
my $col = $row->{$col_name};
$col->{CELL_ROWS} = [ ];
foreach my $i (0 .. scalar(@{ $col->{data} }) - 1) {
} elsif ((1 == scalar @{ $col->{CELL_ROWS} }) && (!defined $col->{CELL_ROWS}->[0]->{data} || ($col->{CELL_ROWS}->[0]->{data} eq ''))) {
$col->{CELL_ROWS}->[0]->{data} = ' ';
}
+
+ push @{ $output_columns }, $col;
+ $skip_next = $col->{colspan} ? $col->{colspan} - 1 : 0;
}
my $row_data = {
- 'COLUMNS' => [ map { $row->{$_} } @visible_columns ],
+ 'COLUMNS' => $output_columns,
'outer_idx' => $outer_idx,
'outer_idx_odd' => $outer_idx % 2,
'inner_idx' => $inner_idx,
return $_[0] * 72 / 2.54;
}
-sub render_pdf_with_pdf_api2 {
+sub generate_pdf_content {
+ eval {
+ require PDF::API2;
+ require PDF::Table;
+ };
+
my $self = shift;
my $variables = $self->prepare_html_content();
my $form = $self->{form};
push @cell_props, $cell_props_row;
foreach my $custom_header_col (@{ $custom_header_row }) {
- push @{ $data_row }, $custom_header_col->{text};
- push @{ $cell_props_row }, {};
+ push @{ $data_row }, $custom_header_col->{text};
+
+ my $num_output = ($custom_header_col->{colspan} * 1 > 1) ? $custom_header_col->{colspan} : 1;
+ if ($num_output > 1) {
+ push @{ $data_row }, ('') x ($num_output - 1);
+ push @{ $cell_props_row }, { 'colspan' => $num_output };
+ push @{ $cell_props_row }, ({ }) x ($num_output - 1);
+
+ } else {
+ push @{ $cell_props_row }, {};
+ }
}
}
}
}
foreach my $row (@{ $row_set }) {
- $data_row = [];
- push @data, $data_row;
+ $data_row = [];
+ $cell_props_row = [];
+
+ push @data, $data_row;
+ push @cell_props, $cell_props_row;
my $col_idx = 0;
foreach my $col_name (@visible_columns) {
$column_props[$col_idx]->{justify} = 'right' if ($col->{align} eq 'right');
- $col_idx++;
- }
+ my $cell_props = { };
+ push @{ $cell_props_row }, $cell_props;
- $cell_props_row = [];
- push @cell_props, $cell_props_row;
+ if ($col->{colspan} && $col->{colspan} > 1) {
+ $cell_props->{colspan} = $col->{colspan};
+ }
- foreach (0 .. $num_columns - 1) {
- push @{ $cell_props_row }, { };
+ $col_idx++;
}
}
}
},
'column_props' => \@column_props,
'cell_props' => \@cell_props,
+ 'max_word_length' => 60,
);
foreach my $page_num (1..$pdf->pages()) {
}
}
-sub generate_pdf_content {
- my $self = shift;
-
- eval { require PDF::API2; require PDF::Table; };
-
- return $self->render_pdf_with_pdf_api2(@_);
-}
-
sub unescape_string {
my $self = shift;
my $text = shift;
$csv->print($stdout, [ map { $self->unescape_string($self->{columns}->{$_}->{text}) } @visible_columns ]);
} else {
- foreach my $custom_header_row (@{ $self->{custom_headers} }) {
- $csv->print($stdout, [ map { $self->unescape_string($_->{text}) } @{ $custom_header_row } ]);
+ foreach my $row (@{ $self->{custom_headers} }) {
+ my $fields = [ ];
+
+ foreach my $col (@{ $row }) {
+ my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1;
+ push @{ $fields }, ($self->unescape_string($col->{text})) x $num_output;
+ }
+
+ $csv->print($stdout, $fields);
}
}
}
next if ('ARRAY' ne ref $row_set);
foreach my $row (@{ $row_set }) {
my @data;
+ my $skip_next = 0;
foreach my $col (@visible_columns) {
+ if ($skip_next) {
+ $skip_next--;
+ next;
+ }
+
+ my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1;
+ $skip_next = $num_output - 1;
+
push @data, join($eol, map { s/\r?\n/$eol/g; $_ } @{ $row->{$col}->{data} });
+ push @data, ('') x $skip_next if ($skip_next);
}
+
$csv->print($stdout, \@data);
}
}