comparison cpt_psm_plotter/lib/CPT/Writer/Spreadsheet/XLSX.pm @ 0:54c7a3ea81e2 draft

Uploaded
author cpt
date Tue, 05 Jul 2022 05:40:36 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:54c7a3ea81e2
1 package CPT::Writer::Spreadsheet::XLSX;
2 use Moose;
3 with 'CPT::Writer', 'CPT::Writer::Spreadsheet';
4 use Excel::Writer::XLSX;
5
6 #http://search.cpan.org/~jmcnamara/Excel-Writer-XLSX/lib/Excel/Writer/XLSX.pm#SPEED_AND_MEMORY_USAGE
7 #
8 #The effect of this is that Excel::Writer::XLSX is about 30% slower than Spreadsheet::WriteExcel and uses 5 times more memory.
9 #
10 #This memory usage can be reduced almost completely by using the Workbook set_optimization() method:
11 #
12 # $workbook->set_optimization();
13 #
14 sub process {
15 my ($self) = @_;
16 if ( $self->galaxy_override ) {
17 die 'This class currently incompatible with Galaxy';
18 }
19 my $workbook = Excel::Writer::XLSX->new(
20 join( '.', $self->outfile(), $self->suffix() ) );
21 $workbook->set_optimization();
22 my %data = %{ $self->data };
23 my @sheets = keys %data;
24 foreach (@sheets) {
25 my $current_worksheet = $workbook->add_worksheet($_);
26 my $data_struc_ref = $data{$_};
27
28 #R,C,AR
29 $current_worksheet->write_row( 0, 0,
30 ${$data_struc_ref}{'header'} );
31 my $row = 1;
32 foreach ( @{ ${$data_struc_ref}{'data'} } ) {
33 $current_worksheet->write_row( $row, 0, $_ );
34 $row++;
35 }
36 }
37 $self->processed_data($workbook);
38 $self->processing_complete(1);
39 }
40
41 sub write {
42 my ($self) = @_;
43 $self->processed_data()->close();
44 }
45
46 sub suffix {
47 return 'xlsx';
48 }
49 no Moose;
50 1;
51
52 __END__
53
54 =pod
55
56 =encoding UTF-8
57
58 =head1 NAME
59
60 CPT::Writer::Spreadsheet::XLSX
61
62 =head1 VERSION
63
64 version 1.99.4
65
66 =head1 AUTHOR
67
68 Eric Rasche <rasche.eric@yandex.ru>
69
70 =head1 COPYRIGHT AND LICENSE
71
72 This software is Copyright (c) 2014 by Eric Rasche.
73
74 This is free software, licensed under:
75
76 The GNU General Public License, Version 3, June 2007
77
78 =cut