1 % $csv->combine(@$header); #or die $csv->status;
3 <% $opt{no_csv_header} ? '' : $csv->string %>\
5 % foreach my $row ( @$rows ) {
7 % if ( $opt{'fields'} ) {
11 % foreach my $field ( @{$opt{'fields'}} ) {
12 % if ( ref($field) eq 'CODE' ) {
15 % ? '(N/A)' #unimplemented
20 % push @line, $row->$field();
24 % $csv->combine(@line); #or die $csv->status;
27 % $csv->combine(@$row); #or die $csv->status;
37 my $header = $args{'header'};
38 my $rows = $args{'rows'};
39 my %opt = %{ $args{'opt'} };
41 #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
42 #http_header('Content-Type' => 'text/plain' );
43 http_header('Content-Type' => 'text/csv' ); # So saith RFC 4180
44 http_header('Content-Disposition' =>
45 'attachment;filename="'.($opt{'name'} || PL($opt{'name_singular'}) ).'.csv"');
48 $quote_char = $opt{csv_quote} if exists($opt{csv_quote});
50 my $csv = new Text::CSV_XS { 'always_quote' => $opt{avoid_quote} ? 0 : 1,
51 'eol' => "\n", #"\015\012", #"\012"