3 Excel spreadsheet view.
9 my $group_info = $m->comp('core', %opt);
11 # minor false laziness with search-xls.html
13 $override = 'XLSX' if grep { $_->num_rows >= 65536 }
14 @{ $group_info->{groups} };
16 my $format = $FS::CurrentUser::CurrentUser->spreadsheet_format($override);
18 my $filename = $opt{'name'} || PL($opt{'name_singular'});
19 $filename .= $format->{extension};
21 http_header('Content-Type' => $format->{mime_type} );
22 http_header('Content-Disposition' => qq!attachment;filename="$filename"! );
23 $HTML::Mason::Commands::r->headers_out->{'Cache-control'} = 'max-age=0';
26 my $XLS = new IO::Scalar \$data;
27 my $workbook = $format->{class}->new($XLS)
28 or die "Error opening Excel file: $!";
30 my $title = $opt{'title'};
31 $title =~ s/[\[\]\:\*\?\/\/]//g;
32 $title = substr($title, 0, 31);
34 for (my $curr_group = 0; $curr_group < $group_info->{num}; $curr_group++) {
35 my $group = $group_info->{groups}[$curr_group];
36 my $query = $group_info->{queries}[$curr_group];
37 my $footer = $group_info->{group_footers}[$curr_group];
38 my $label = $group_info->{group_labels}[$curr_group];
40 my @rows = $query->qsearch;
41 #warn Dumper(\@rows); #DEBUG
43 # pass arrayrefs to write_row to write multiple rows
44 $opt{footer} = [ List::MoreUtils::pairwise { [ $a, $b ] }
46 @{$group_info->{total_footer}}
48 $m->comp('/search/elements/search-xls.html:worksheet',
49 workbook => $workbook,
51 header => $opt{header},