Aller directement au contenu principal

ExcelExportAsPDF

Structure

TCommonLibrary.ExcelExportAsPDF(AMachine:TatVirtualMachine); // (sExcelFileName, sPDFFileName, bIncludeDocProperties, bIgnorePrintArea, iPageFrom, iPageTo, bOpenAfterPublish)

Type

Procédure

Description

La procédure TCommonLibrary.ExcelExportAsPDF sert de passerelle vers la méthode ExportAsFixedFormat de l'automatisation OLE d'Excel (pilotes Windows). Cela signifie que, pour fonctionner correctement, cette procédure nécessite l'installation d'Excel sur le serveur.

Si le script parvient à ouvrir le document via OLE (comme avec la méthode [Workbooks.Open (Excel) | Microsoft Learn](https://learn.microsoft.com/en-us/office/vba/api/excel.workbooks.open « https://learn.microsoft.com/en-us/office/vba/api/excel.workbooks.open »)), il transmet alors toutes les variables à la fonction ExportAsFixedFormat, comme indiqué ici : Méthode Worksheet.ExportAsFixedFormat (Excel) | Microsoft Learn

Le seul paramètre défini de manière fixe est le deuxième paramètre « Quality », qui est réglé sur « Standard » (0).

Appel de script en coulisses :

//Ouvrir le classeur Excel
try
ExcelWorkbook := ExcelApplication.Workbooks.Open(sExcelFileName);
//référence
//https://docs.microsoft.com/en-us/office/vba/api/excel.workbooks.open
except
ExcelWorkbook := Null;
bResult := False;
end;

If VarIsNull(ExcelWorkbook) = False then
begin
Try
ExcelWorkbook.ExportAsFixedFormat(0, sPDFFileName, 0, bIncludeDocProperties, bIgnorePrintArea, iPageFrom, iPageTo, bOpenAfterPublish, EmptyParam);
// référence
//https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.exportasfixedformat
Except
bResult := False;
End;
end;