Il est assez facile de manipuler des fichiers Excel en Perl, via OLE.
Bien sûr celà ne fonctionne que sous Windows, puisqu'on utilise le mécanisme OLE, qui n'est disponible que sur les plate-formes WIN32.
La documentation qui suit n'est pas exhaustive, loin de là. C'est plus un livre de recettes (aka cookbook) pour comprendre les principes de base. A prtir de là, et à l'aide de la doc VB, il est possible de faire de grandes choses !
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
$Excel -> Workbooks -> Open($file_name_path);
my $workbook = $Excel -> Workbooks -> Add;
$workbook -> ActiveSheet -> Range('A1')->{'Value'} = "TOTAL";
$workbook -> SaveAs ("c:\\excel_file.xls") or die $!;
$workbook -> Close();
$Sheet->Cells($row,$col)->{'Value'};
$Sheet->Cells($row, $col)->{'Value'} = 1;
$Sheet->Cells($row,$col)->{'Formula'};
with($workbook -> ActiveSheet -> Columns(1), ColumnWidth => 20, HorizontalAlignment => xlLeft);
$workbook -> ActiveSheet -> {'Name'} = 'Toto';
my $sheet2 = $workbook->Worksheets->Add( {after =>$workbook->Worksheets(1)} );
$sheet2 -> Range('A1')->{'Value'} = 'toto';
$workbook -> ActiveSheet -> Range('C1')->{'NumberFormat'} = "@";
$workbook -> ActiveSheet -> Range('A2:I50001')->{'Value'} = \@part1;
my $rng = $sheet -> Range("C3:BC6");
my $chart_obj = $sheet ->ChartObjects->Add(60, 80, 800, 500);
$chart = $chart_obj->Chart;
$chart->SetSourceData({Source => $rng, PlotBy => xlLines});
$chart->{ChartType} = xlLine;
$chart->{'HasTitle'} = 1;
$chart->ChartTitle->{Text} = "Appels d'offre soumis en $annee_depart et $annee_fin";
$chart->SeriesCollection(1)->{Name} = $annee_depart;
$chart->SeriesCollection(1)->{Border}->{Weight} = xlMedium;
$chart->SeriesCollection(2)->{Name} = "Cumul $annee_depart";
$chart->SeriesCollection(2)->{Border}->{Weight} = xlMedium;
$chart->SeriesCollection(2)->{AxisGroup} = xlSecondary;
$chart->SeriesCollection(3)->{Name} = $annee_fin;
$chart->SeriesCollection(3)->{Border}->{Weight} = xlMedium;
$chart->SeriesCollection(4)->{Name} = "Cumul $annee_fin";
$chart->SeriesCollection(4)->{Border}->{Weight} = xlMedium;
$chart->SeriesCollection(4)->{AxisGroup} = xlSecondary;
$chart->Location(xlLocationAsObject, "Appels d'offres"); # Attention, bien préciser ici le nom de la page, sinon le tableau se retrouve sur une page séparée.
$sheet -> Range("B2:BC2") -> Borders(xlEdgeTop) -> {LineStyle} = xlDouble;
$sheet -> Range("B2:BC2") -> Borders(xlEdgeTop) -> {Weight} = xlThick;
$sheet -> Range("B2:BC2") -> Borders(xlEdgeTop) -> {ColorIndex} = 1;
$sheet -> Range("B2:BC2") -> Borders(xlEdgeBottom) -> {LineStyle} = xlContinuous;
$sheet -> Range("B2:BC2") -> Borders(xlEdgeBottom) -> {Weight} = xlThin;
$sheet -> Range("B2:BC2") -> Borders(xlEdgeBottom) -> {ColorIndex} = 1;
$sheet -> Range("B2:B6") -> Borders(xlEdgeLeft) -> {LineStyle} = xlDouble;
$sheet -> Range("B2:B6") -> Borders(xlEdgeLeft) -> {Weight} = xlThick;
$sheet -> Range("B2:B6") -> Borders(xlEdgeLeft) -> {ColorIndex} = 1;
$sheet -> Range("B6:BC6") -> Borders(xlEdgeBottom) -> {LineStyle} = xlDouble;
$sheet -> Range("B6:BC6") -> Borders(xlEdgeBottom) -> {Weight} = xlThick;
$sheet -> Range("B6:BC6") -> Borders(xlEdgeBottom) -> {ColorIndex} = 1;
$sheet -> Range("BC2:BC6") -> Borders(xlEdgeRight) -> {LineStyle} = xlDouble;
$sheet -> Range("BC2:BC6") -> Borders(xlEdgeRight) -> {Weight} = xlThick;
$sheet -> Range("BC2:BC6") -> Borders(xlEdgeRight) -> {ColorIndex} = 1;
Dans Excel : Outil / Macro / editeur Visual Basic
Puis faire F2 ou Affichage / Explorateur d'objets et choisir Excel dans la combo du haut.
Voila un premier jet, je complèterai au fur et à mesure.