projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
display dates as real dates in Excel export, #23121, update for current RT
[freeside.git]
/
rt
/
share
/
html
/
Search
/
Results.xls
diff --git
a/rt/share/html/Search/Results.xls
b/rt/share/html/Search/Results.xls
index
8146376
..
d9d8356
100644
(file)
--- a/
rt/share/html/Search/Results.xls
+++ b/
rt/share/html/Search/Results.xls
@@
-54,7
+54,9
@@
$Format => undef
<%INIT>
use Spreadsheet::WriteExcel;
<%INIT>
use Spreadsheet::WriteExcel;
+use OLE::Storage_Lite;
use List::Util qw( max );
use List::Util qw( max );
+use Date::Format qw( time2str );
$r->content_type('application/vnd.ms-excel');
$r->header_out('Content-Disposition' => 'attachment;filename="Results.xls"');
$r->content_type('application/vnd.ms-excel');
$r->header_out('Content-Disposition' => 'attachment;filename="Results.xls"');
@@
-69,6
+71,11
@@
my $default_format = $workbook->add_format(
color => 'black',
size => 10,
);
color => 'black',
size => 10,
);
+my $date_format = $workbook->add_format(
+ color => 'black',
+ size => 10,
+ num_format => 'YYYY-MM-DD', #configurable?
+);
my $title_format = $workbook->add_format(
color => 'black',
size => 10,
my $title_format = $workbook->add_format(
color => 'black',
size => 10,
@@
-97,12
+104,26
@@
my $WriteRow = sub {
# record row/column sizes
$height = max( $height, scalar(@lines) );
$width[$item] = max( $width[$item], map {length} @lines );
# record row/column sizes
$height = max( $height, scalar(@lines) );
$width[$item] = max( $width[$item], map {length} @lines );
+
+ if ( scalar(@lines) == 1 and
+ $lines[0] =~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/ ) {
+
+ $worksheet->write_date_time($row, $item, $lines[0], $date_format);
+ next;
+ }
+
$worksheet->write($row, $item, join("\n", @lines), $default_format);
}
$worksheet->set_row($row, $height * 14);
$row++;
};
$worksheet->write($row, $item, join("\n", @lines), $default_format);
}
$worksheet->set_row($row, $height * 14);
$row++;
};
+$m->notes('FormatDate', sub {
+ my $DateObj = shift;
+ return '' if $DateObj->Unix == 0;
+ return time2str('%Y-%m-%dT%H:%M', $DateObj->Unix);
+});
+
# Write everything to the worksheet
$m->comp('Elements/ResultsStructuredView',
Query => $Query,
# Write everything to the worksheet
$m->comp('Elements/ResultsStructuredView',
Query => $Query,