Frage

Can anybody tell me how to export an excel spreadsheet to pdf using delphi code?

I know there is a command in the MS Word OLE object for exporting to PDf, but I cannot find anything about Excel.

Word To PDF Example:

Const
 wdExportFormatPDF = 17;

 WrdDoc.ExportAsFixedFormat(SaveToFile, wdExportFormatPDF);
War es hilfreich?

Lösung

The correct code is

wb.ExportAsFixedFormat(xlTypePDF, FileName);

or

sheet.ExportAsFixedFormat(xlTypePDF, FileName);

where wb is a workbook and sheet is a worksheet. If for some reason, your import library does not define xlTypePDF, it has value 0.

Some documentation links:

If you read the documentation carefully you will discover that you have been passing the parameters in the wrong order.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top