transform

transform

ADVANCED / PREMIUM BASIC

Transforms spreadsheets into other formats (XLSX, PDF, XLS, ODS).

Description
public transform($source, $target, $method = null, $options = array())

This method allows to transform a spreadsheet, generated or not with phpxlsx, into PDF, XLSX, XLS and ODS preserving, as much as possible, the original formatting options.

You may find more info regarding this method in the Conversion plugin section.

Parameters

source

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

target

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

method

Method used to transform the spreadsheet: 'libreoffice', 'msexcel'

'libreoffice' method options

The possible keys and values are:

Key Type Description
debug bool Returns debug information about the conversion plugin. Default as false
extraOptions string Extra parameters to be used when doing the conversion.
homeFolder string Sets a custom home folder to be used for the conversions.
outdir string Sets the outdir path. Useful when the output path is not the same than the running script.
recalcFunctions bool Recalcs functions when transforming to PDF. Default as false
Code samples

Example #1

The resulting output looks like:

Release notes
  • phpxlsx 3.5:
    • recalcFunctions option.
  • phpxlsx 1.0:
    • new method.