Escolar Documentos
Profissional Documentos
Cultura Documentos
Ou comment produire des rapports pour son manager sans dgainer Excel
Laurent Boivin
Premier contact
Laurent Boivin
Premier contact
Laurent Boivin
Premier contact
!n 3e format de sortie :
un fichier Excel
Laurent Boivin
Laurent Boivin
"
SpreadSheet::#arseExcel::Simple SpreadSheet::(riteExcel +isponibles sur le C#,* #ur #erl donc--- multi.OS Et (in32::O0E 1
atta2ue directement les -+00 3ia le mcanisme d4O0E ncessite 2ue MS Excel soit install sur le poste multi.(indo5s
/
Laurent Boivin
Spreadsheet::ParseExcel::Simple
my $xls = Spreadsheet::ParseExcel::Simple->read(!;
Laurent Boivin
C4est Simple
7
on vrai ! classeur
er
use Spreadsheet::ParseExcel; my $wb = Spreadsheet::ParseExcel::*or(boo(->Parse($f!; foreach my $sh ($"$wb->"*or(sheet''! " $sh->"+ax,ow' --= $sh->"+i%,ow'; foreach my $r ($sh->"+i%,ow' foreach my $c ($sh->"+i%.ol' if ($cell! " push $data1 $cell->"2al'!; '
Laurent Boivin
texte : le texte tel 2uel nombre : =>E*ER,0= pour le format par dfaut, la 3aleur sinon formule : cela dpend si le dernier rsultat calcul est un nombre ou un texte
9:
Laurent Boivin
plus souple dans la fa@on de lire de rcuprer les donnes rcuprer brutalement une feuille est plus long A crire mBme comportement par rapport au =calcul automati2ue=
99
Laurent Boivin
' $wb->close(!;
92
& 76
' $wb->close(!;
93
Laurent Boivin
9"
Laurent Boivin
9/
$wb->write($r1$c1"=sum(76:7<!"!;
Laurent Boivin
96
E l4excution : .ould%3t parse formula: =somme(76:7<! E l4excution : .ould%3t parse formula: =sum(76:7<!
$wb->write($r1$c1"=sum(76:7<!"!;
Laurent Boivin
La "ormule du che"
Ma 9;re ruse :
$wb->write($r1$c13sum(76:7<!3!; et on aGoute le + dans le tableur
Laurent Boivin
98
La "ormule du che"
Ma 9;re ruse :
$wb->write($r1$c13=sum(76:7<!3!; et on aGoute le + dans le tableur
Laurent Boivin
2:
;raphe bi% doit a3oir t extrait d4un fichier Excel my $chart = $wb->add#chart#ext(3chart46 bi%31 3.hart63!; =%his feature is ne5 and 5ould be best described as experimental-=
Laurent Boivin
29
Laurent Boivin
22
$wb->add#wor(sheet("%om"!; foreach $ws ($wb->sheets(!! " pri%t $ws->;et#%ame(!; ' foreach $ws ($wb->sheets(416!! " pri%t $ws->;et#%ame(!; ' ---
Laurent Boivin
23
0argeur des colonnes, hauteur des lignes Hormat de la page $impression' Higer les lignesIcolonnes Choix de l4encodage des caract;res +part de la date $986: ou 98: ' >roupage de lignes --2
Laurent Boivin
-uelques exemples
Laurent Boivin
2"
$omparaison de parc
#roblmati2ue :
Croiser des donnes &O $/::: entres' et Excel $92::: #C' %ous les mois
Laurent Boivin
2/
$omparaison de parc
Extraction des donnes &O 3ers Excel Hiltre a3ec Excel pour rduire de 92::: #C A 3::: 0ecture des in3entaires a3ec S::#E::S On mouline Cration du rapport a3ec S::(E On l4en3oie A sa chef
Laurent Boivin
26
$r'ation du rapport
my my my my if $wor(boo( = Spreadsheet::*riteExcel->%ew($f%ame!; $bold = $wor(boo(->add#format(bold => 6!; $ws = $wor(boo(->add#wor(sheet(3Co be serDiced3!; $row = 4; ( scalar $hp#headers ! " my $col = 4; foreach my $h ( $hp#headers ! " $ws->write($row1 $col1 $h1 $bold!; $col EE; ' $rowEE;
Laurent Boivin
' foreach my $( ( sort $to#be#serDiced ! " my $col = 4; foreach my $i ( $ "$hp"$('' ! " $ws->write($row1 $col1 $i!; $colEE; ' $rowEE; '
27
28
!./
& *rite the headers my $c = 4; map " $ws->write(41 $cEE1 $#1 $format->"header'!;' $$headers; & *rite the co%te%t my $r = 6; & cou%t the rows for the fi%al total foreach my $( ( sort (eys I$data ! " my $9 = ;et#9o%e($data->"$('"3JPEK 87CE3'!; & Lill the colum% with 3c3 ce%tered cells: map " $ws->write($r1 $#1 $data->"$('->"$headers>/$#0'1 $format->"$9'"c'!; ' $"$f#of#h->"3c3'';
Laurent Boivin
&
3:
(./
& Lill the colum% with 3-3 %eutral cells (%o specific format! map " $ws->write($r1 $#1 $data->"$('->"$headers>/$#0'1 $format->"$9'"%'!; ' $"$f#of#h->"3-3''; $rEE; ' $ws->write($r1 51 "JPEK E .MJSE8 = CJC7M"1 $format>"94'"%'!; $ws->write($r1 N1 3.JK.7CEK7CE(.J=KC(O?:O3 $r 3!S=+(O?:O3 $r 3!1" E "1S=+(O?:O3 $r 3!1" = "1.J=KC(O?:O3 $r 3!!31 $format->"94'"%'!; $ws->write($rE?1 51 38o%t *iLi :31 $format->"94'"%'!; $ws->write($rE?1 N1 3.J=KCPL(P?:P3 $r 31 "*PLPQ"!31 $format->"94'"%'!;
39
Laurent Boivin
/./
Laurent Boivin
& Lormat the pri%t out & Si9e the colum% (based o% experime%ts as 37utoLit3 ca% be specified! $ws->set#colum%(41 41 R!; $ws->set#colum%(61 61 54!; $ws->set#colum%(?1 ?1 5!; $ws->set#colum%(51 51 ?@!; $ws->set#colum%(@1 @1 N!; $ws->set#colum%(A1 A1 6?!; $ws->set#colum%(:1 :1 N!; $ws->set#colum%(N1 N1 6R!; $ws->set#colum%(R1 R1 A4!; $ws->free9e#pa%es(61 4!; $ws->set#la%dscape(!; $ws->set#mar;i%s(4 A!; $ws->pri%t#area(37:P3!; $ws->repeat#rows(4!;
32