Conversion plugin phpxlsx

Running the first example and available options

Running the first example

You can transform files with the CreateXlsx class methods or directly calling the transformation classes.

This would be an easy example to create a XLSX and convert it to PDF:

Or to transform an existing XLSX:

The conversion plugin type to use in both examples is the one defined in the configuration file config/phpxlsxconfig.ini.

Available options

The transform method has some parameters which you may have to customize.

Here's the signature of the method:

These are the available parameters:

source

Path to the XLSX that you want to convert to a different format.

target

Path to the resulting transformed document (PDF, XLS or ODS).

method

Method used to transform the document: 'libreoffice', 'msexcel'.

'libreoffice' method options

The possible keys and values are:

Key Type Description
debug bool False by default. Returns debug information about the conversion plugin.
extraOptions string Extra parameters to be used when doing the conversion.
homeFolder string Set a custom home folder to be used for the conversions.
outdir string Set the outdir path. Useful when the PDF output path is not the same than the running script.

'msexcel' method options

The possible keys and values are:

Key Type Description
selectedContent string Scope: 'active' (default) or 'documents'.
Transformation classes

If you don't need to generate a new spreadsheet and you just need to make the conversion, you can directly instantiate the following classes:

  • TransformLibreOffice, for LibreOffice
  • TransformMSExcel, for MS Excel

Working with these classes is as simple as including the autoloader:

Then instantiate an object with the desired class:

For LibreOffice:

for MS Excel:

And then call the transformation:

The transformation classes don't have a method option.

Next - Preparing the documents for their conversion