PhpSpreadsheet PdfExporterType
The PdfExporterType
represents an exporter that uses an PhpSpreadsheet PDF writer.
Options
sheet_index
- type:
null
orint
- default:
0
PDF files can only contain one or more worksheets. Therefore, you can specify which sheet to write to PDF. If you want to write all sheets into a single PDF file, set this option to null
.
images_root
- type:
string
- default:
''
There might be situations where you want to explicitly set the included images root. For example, instead of:
<img src="./images/logo.jpg">
You might want to see:
<img src="https://www.domain.com/images/logo.jpg">
Use this option to achieve this result:
use Kreyu\Bundle\DataTableBundle\Bridge\PhpSpreadsheet\Exporter\Type\PdfExporterType;
$builder
->addExporter('html', PdfExporterType::class, [
'images_root' => 'https://www.domain.com',
])
;
embed_images
- type:
bool
- default:
false
Determines whether the images should be embedded or not.
use_inline_css
- type:
bool
- default:
false
Determines whether the inline css should be used or not.
generate_sheet_navigation_block
- type:
bool
- default:
true
Determines whether the sheet navigation block should be generated or not.
edit_html_callback
- type:
null
orcallable
- default:
null
Accepts a callback function to edit the generated html before saving. For example, you could change the gridlines from a thin solid black line:
use Kreyu\Bundle\DataTableBundle\Bridge\PhpSpreadsheet\Exporter\Type\PdfExporterType;
$builder
->addExporter('html', PdfExporterType::class, [
'edit_html_callback' => function (string $html): string {
return str_replace(
'{border: 1px solid black;}',
'{border: 2px dashed red;}',
$html,
);
}
])
;
decimal_separator
- type:
string
- default: depends on the server's locale setting
If the worksheet you are exporting contains numbers with decimal separators, then you should think about what characters you want to use for those before doing the export.
By default, PhpSpreadsheet looks up in the server's locale settings to decide what character to use. But to avoid problems, it is recommended to set the character explicitly.
thousands_separator
- type:
string
- default: depends on the server's locale setting
If the worksheet you are exporting contains numbers with thousands separators, then you should think about what characters you want to use for those before doing the export.
By default, PhpSpreadsheet looks up in the server's locale settings to decide what character to use. But to avoid problems, it is recommended to set the character explicitly.
Inherited options
use_headers
- type:
bool
- default:
true
Determines whether the exporter should add headers to the output file.
label
- type:
null
orstring
- default:
null
the label is "guessed" from the exporter name
Sets the label of the exporter, visible in the export action modal.
tempnam_dir
- type:
string
- default: the value returned by the
sys_get_temp_dir()
function
Sets the directory used to store temporary file during the export process.
tempnam_prefix
- type:
string
- default:
exporter_
Sets the prefix used to generate temporary file names during the export process.
pre_calculate_formulas
- type:
bool
- default:
true
By default, the PhpSpreadsheet writers pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. The value of this option determines whether the formula pre-calculation is enabled.