| 1 | package Spreadsheet::ExcelHashTable; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Spreadsheet::ParseExcel; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Spreadsheet::WriteExcel; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Tie::IxHash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Spreadsheet::ExcelHashTable - Converts Excel Table to Perl Hash and vicerversa | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 VERSION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Version 0.02 | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 24 | 0 | my $self = { | |||||||||||||||||||||||||||
| 25 | excel_hash => {}, | ||||||||||||||||||||||||||||
| 26 | excel_file => '', | ||||||||||||||||||||||||||||
| 27 | excel_sheet => '', | ||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | 0 | bless ( $self, $class); | |||||||||||||||||||||||||||
| 30 | 0 | tie %{$self->{excel_hash}}, "Tie::IxHash"; | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | $self->{excel_file} = shift if(@_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | my $parser = Spreadsheet::ParseExcel->new(); | |||||||||||||||||||||||||||
| 33 | 0 | $self->{excel_obj} = $parser->parse($self->{excel_file}); | |||||||||||||||||||||||||||
| 34 | 0 | return $self; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub set_read_xls { | ||||||||||||||||||||||||||
|
Subroutine
set_read_xls: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | 0 | $self->{excel_file} = shift ; | |||||||||||||||||||||||||||
| 40 | 0 | my $parser = Spreadsheet::ParseExcel->new(); | |||||||||||||||||||||||||||
| 41 | 0 | $self->{excel_obj} = $parser->parse($self->{excel_file}); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub parse_table { | ||||||||||||||||||||||||||
|
Subroutine
parse_table: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | 0 | my $sheet = shift; | |||||||||||||||||||||||||||
| 47 | 0 | my $var = shift; | |||||||||||||||||||||||||||
| 48 | 0 | $self->{excel_sheet} = $sheet; | |||||||||||||||||||||||||||
| 49 | 0 | $self->{sheet_obj} = $self->{excel_obj}->worksheet($sheet); | |||||||||||||||||||||||||||
| 50 | 0 | $self->{table_name} = $var; | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($self->excel_checker()) { $self->error(); die; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | my $cell_info = $self->_search_var($var); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( ! exists $self->{excel_hash}->{$var} ) { $self->{excel_hash}->{$var} = {}; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | my ($row_v, $col_v) = split " ", $cell_info; | |||||||||||||||||||||||||||
| 55 | 0 | my $row_v_max = $self->_get_table_row_max($row_v, $col_v); | |||||||||||||||||||||||||||
| 56 | 0 | my $col_v_max = $self->_get_table_col_max($row_v, $col_v); | |||||||||||||||||||||||||||
| 57 | 0 | $self->_get_table_hash($row_v, $col_v, $row_v_max, $col_v_max); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _get_table_hash { | ||||||||||||||||||||||||||
|
Subroutine
_get_table_hash: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my ($row, $col, $row_max, $col_max) = @_; | |||||||||||||||||||||||||||
| 63 | 0 | foreach my $r ($row+1 ... $row_max ) { | |||||||||||||||||||||||||||
| 64 | 0 | my $row_key = $self->{sheet_obj}->get_cell($r,$col)->value ; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($row_key =~ /\s+$/ ) { $row_key =~ s/\s+$//g ; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | chop($row_key) if ($row_key =~ /\s+$/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | $self->{excel_hash}->{$self->{table_name}}->{$row_key} = {}; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | foreach my $c ($col+1 ... $col_max) { | |||||||||||||||||||||||||||
| 70 | 0 | my $r = $row+1; | |||||||||||||||||||||||||||
| 71 | 0 | my $row_key = $self->{sheet_obj}->get_cell($r,$col)->value; | |||||||||||||||||||||||||||
| 72 | 0 | my $att = $self->{sheet_obj}->get_cell($row,$c)->value; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $att =~ /\s+$/ ) { $att =~ s/\s+$//g; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $row_key =~ /\s+$/ ) { $row_key =~ s/\s+$//g; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | $self->{excel_hash}->{$self->{table_name}}->{$row_key}->{$att} = ""; | |||||||||||||||||||||||||||
| 76 | 0 | $r = $r + 1; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 0 | foreach my $r ( $row+1 ... $row_max ) { | |||||||||||||||||||||||||||
| 79 | 0 | foreach my $c ( $col+1 ... $col_max ) { | |||||||||||||||||||||||||||
| 80 | 0 | my $val = ""; | |||||||||||||||||||||||||||
| 81 | 0 | my $cell = $self->{sheet_obj}->get_cell($r,$c); | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( defined $cell ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | $val = $cell->value(); | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | chop($val) if ($val =~ /\s+$/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 0 | my $row_key = $self->{sheet_obj}->get_cell($r,$col)->value; | |||||||||||||||||||||||||||
| 87 | 0 | my $col_key = $self->{sheet_obj}->get_cell($row, $c)->value; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($row_key =~ /\s+$/ ) { $row_key =~ s/\s+$//g; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ($col_key =~ /\s+$/ ) { $col_key =~ s/\s+$//g; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | $self->{excel_hash}->{$self->{table_name}}->{$row_key}->{$col_key} = $val; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub _get_table_col_max { | ||||||||||||||||||||||||||
|
Subroutine
_get_table_col_max: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | 0 | my $row_v = shift; | |||||||||||||||||||||||||||
| 97 | 0 | my $col_v = shift; | |||||||||||||||||||||||||||
| 98 | 0 | my $col_v_max = $col_v; | |||||||||||||||||||||||||||
| 99 | 0 | my ( $row_min, $row_max) = $self->{sheet_obj}->row_range; | |||||||||||||||||||||||||||
| 100 | 0 | my ( $col_min, $col_max) = $self->{sheet_obj}->col_range; | |||||||||||||||||||||||||||
| 101 | 0 | foreach my $col ( $col_v ... $col_max ) { | |||||||||||||||||||||||||||
| 102 | 0 | $col_v_max = $col; | |||||||||||||||||||||||||||
| 103 | 0 | my $cell = $self->{sheet_obj}->get_cell($row_v, $col); | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ( ! defined $cell ) { $col_v_max = $col-1; last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $cell->value eq "" ) { $col_v_max = $col-1; last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( $col_v_max == $col_v ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 0 | my $msg = "ERROR: It is not a Valid Table to create Hash. Double Check <$self->{table_name}>"; | |||||||||||||||||||||||||||
| 109 | 0 | $self->{error_hash}->{$msg} = ""; | |||||||||||||||||||||||||||
| 110 | 0 | return ""; | |||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||
| 112 | 0 | return $col_v_max; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||
|
Subroutine
error: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 118 | 0 | foreach my $msg ( keys %{$self->{error_hash}} ) { | |||||||||||||||||||||||||||
| 119 | 0 | print "\n\t$msg\n"; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub _get_table_row_max { | ||||||||||||||||||||||||||
|
Subroutine
_get_table_row_max: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 0 | my $row_v = shift; | |||||||||||||||||||||||||||
| 127 | 0 | my $col_v = shift; | |||||||||||||||||||||||||||
| 128 | 0 | my $row_v_max = $row_v; | |||||||||||||||||||||||||||
| 129 | 0 | my ( $row_min, $row_max) = $self->{sheet_obj}->row_range; | |||||||||||||||||||||||||||
| 130 | 0 | my ( $col_min, $col_max) = $self->{sheet_obj}->col_range; | |||||||||||||||||||||||||||
| 131 | 0 | foreach my $row ( $row_v ... $row_max ) { | |||||||||||||||||||||||||||
| 132 | 0 | $row_v_max = $row; | |||||||||||||||||||||||||||
| 133 | 0 | my $cell = $self->{sheet_obj}->get_cell($row, $col_v); | |||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( ! defined $cell ) { $row_v_max = $row-1; last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( $cell->value eq "" ) { $row_v_max = $row-1; last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ( $row_v_max == $row_v ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | my $msg = "ERROR: It is not a Valid Table to create Hash. Double Check <$self->{table_name}>"; | |||||||||||||||||||||||||||
| 139 | 0 | $self->{error_hash}->{$msg} = ""; | |||||||||||||||||||||||||||
| 140 | 0 | return ""; | |||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||
| 142 | 0 | return $row_v_max; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub _search_var { | ||||||||||||||||||||||||||
|
Subroutine
_search_var: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 147 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 148 | 0 | my $var = shift; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | my ( $row_min, $row_max ) = $self->{sheet_obj}->row_range; | |||||||||||||||||||||||||||
| 151 | 0 | my ( $col_min, $col_max) = $self->{sheet_obj}->col_range; | |||||||||||||||||||||||||||
| 152 | 0 | foreach my $col ($col_min ... $col_max ) { | |||||||||||||||||||||||||||
| 153 | 0 | foreach my $row ( $row_min ... $row_max ) { | |||||||||||||||||||||||||||
| 154 | 0 | my $cell = $self->{sheet_obj}->get_cell($row, $col); | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ( defined $cell ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | my $val = $cell->value; | |||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($val =~ /\s+$/ ) { $val =~ s/\s+//g; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $val eq "$var") { return "$row $col"; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | 0 | my $msg = "ERROR: No Cell found with <$var> value in <$self->{excel_file} : $self->{excel_sheet}, Make Sure it is Valid Excel Table\n"; | |||||||||||||||||||||||||||
| 163 | 0 | $self->{error_hash}->{$msg} = ""; | |||||||||||||||||||||||||||
| 164 | 0 | return ""; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub excel_checker { | ||||||||||||||||||||||||||
|
Subroutine
excel_checker: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | my $sheet = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | my $var = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ( ! defined $var ) { $var = $self->{table_name} ; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( ! defined $sheet ) { $sheet = $self->{excel_sheet} ; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | $self->{sheet_obj} = $self->{excel_obj}->worksheet($sheet); | |||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (! defined $self->{sheet_obj} ) { $self->{error_hash}->{"Work Sheet $sheet Not found in $self->{excel_file}"} = "" ; return 1;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 0 | my $cell_info = $self->_search_var($var); | |||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ( $cell_info eq "" ) { return 1 ; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 0 | my ($row_v, $col_v ) = split " " , $cell_info; | |||||||||||||||||||||||||||
| 178 | 0 | my $row_v_max = $self->_get_table_row_max($row_v, $col_v); | |||||||||||||||||||||||||||
| 179 | 0 | my $col_v_max = $self->_get_table_col_max($row_v, $col_v); | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( $col_v_max eq "" || $row_v_max eq "" ) { return 1; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$col_v_max eq "" or $row_v_max eq ""
MC/DC0%0/2
$col_v_max eq "" or $row_v_max eq ""
$col_v_max eq ""
$row_v_max eq ""
Truth table0%0/3
A or B
A= $col_v_max eq ""B= $row_v_max eq ""
| |||||||||||||||||||||||||||||
| 181 | 0 | undef $var; | |||||||||||||||||||||||||||
| 182 | 0 | undef $sheet; | |||||||||||||||||||||||||||
| 183 | 0 | return 0; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub _print_table { | ||||||||||||||||||||||||||
|
Subroutine
_print_table: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 187 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 188 | 0 | foreach my $key ( keys %{$self->{excel_hash}} ) { | |||||||||||||||||||||||||||
| 189 | 0 | print "Table: >$key< \n"; | |||||||||||||||||||||||||||
| 190 | 0 | foreach my $k ( keys %{$self->{excel_hash}->{$key}} ) { | |||||||||||||||||||||||||||
| 191 | 0 | print ">$k<:\n"; | |||||||||||||||||||||||||||
| 192 | 0 | foreach my $j ( keys %{$self->{excel_hash}->{$key}->{$k}} ) { | |||||||||||||||||||||||||||
| 193 | 0 | print ">$j<: >$self->{excel_hash}->{$key}->{$k}->{$j}<\n"; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub set_write_xls { | ||||||||||||||||||||||||||
|
Subroutine
set_write_xls: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | 0 | my $xls = shift; | |||||||||||||||||||||||||||
| 202 | 0 | $self->{work_book_obj} = Spreadsheet::WriteExcel->new($xls); | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub write_excel { | ||||||||||||||||||||||||||
|
Subroutine
write_excel: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 206 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 207 | 0 | my $worksheet = shift; | |||||||||||||||||||||||||||
| 208 | 0 | my $table = shift; | |||||||||||||||||||||||||||
| 209 | 0 | my $work_sheet = $self->{work_book_obj}->add_worksheet($worksheet); | |||||||||||||||||||||||||||
| 210 | 0 | my $row = 2; | |||||||||||||||||||||||||||
| 211 | 0 | my $col = 2; | |||||||||||||||||||||||||||
| 212 | 0 | my $format = $self->{work_book_obj}->add_format(); | |||||||||||||||||||||||||||
| 213 | 0 | $format->set_bold(); | |||||||||||||||||||||||||||
| 214 | 0 | $format->set_color("blue"); | |||||||||||||||||||||||||||
| 215 | 0 | $format->set_align("center"); | |||||||||||||||||||||||||||
| 216 | 0 | $work_sheet->write($row, $col, $table, $format ); | |||||||||||||||||||||||||||
| 217 | 0 | foreach my $row_key ( keys %{$self->{excel_hash}->{$table}} ) { | |||||||||||||||||||||||||||
| 218 | 0 | $row = $row + 1; | |||||||||||||||||||||||||||
| 219 | 0 | $work_sheet->write($row, $col, $row_key, $format ); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | 0 | $row = 2; | |||||||||||||||||||||||||||
| 222 | 0 | foreach my $row_key ( keys %{$self->{excel_hash}->{$table}} ) { | |||||||||||||||||||||||||||
| 223 | 0 | $col = 2; | |||||||||||||||||||||||||||
| 224 | #print "$row_key\n"; | ||||||||||||||||||||||||||||
| 225 | 0 | foreach my $col_key ( keys %{$self->{excel_hash}->{$table}->{$row_key}} ) { | |||||||||||||||||||||||||||
| 226 | #print "$row $col $col_key\n"; | ||||||||||||||||||||||||||||
| 227 | 0 | $col = $col + 1; | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | if( $row == 2) { $work_sheet->write($row, $col, $col_key, $format ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | $work_sheet->write($row+1, $col, $self->{excel_hash}->{$table}->{$row_key}->{$col_key} ); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | 0 | $row = $row +1; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub get_table { | ||||||||||||||||||||||||||
|
Subroutine
get_table: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | 0 | my $table = shift; | |||||||||||||||||||||||||||
| 238 | 0 | return $self->{excel_hash}->{$table}; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub get_xl_tables { | ||||||||||||||||||||||||||
|
Subroutine
get_xl_tables: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 242 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 243 | 0 | return $self->{excel_hash}; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 2 | 1; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | __END__ | ||||||||||||||||||||||||||||