Vai al contenuto principale

Esporta in PDF da Excel

Struttura

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

Tipo

Procedura

Descrizione

La procedura TCommonLibrary.ExcelExportAsPDF funge da passerella per il metodo ExportAsFixedFormat nell'automazione OLE di Excel (driver di Windows). Ciò significa che, affinché la procedura funzioni correttamente, è necessario che Excel sia installato sul server.

Se lo script è in grado di aprire il documento tramite OLE (come nel caso del metodo Workbooks.Open (Excel) | Microsoft Learn), allora passa tutte le variabili alla funzione ExportAsFixedFormat, come documentato qui: Metodo Worksheet.ExportAsFixedFormat (Excel) | Microsoft Learn

L'unico parametro predefinito è il secondo parametro Quality, impostato su Standard (0).

Chiamata tecnica dietro le quinte:

//Apri cartella di lavoro Excel
try
ExcelWorkbook := ExcelApplication.Workbooks.Open(sExcelFileName);
//riferimento
//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);
// riferimento
//https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.exportasfixedformat
Except
bResult := False;
End;
end;