Skip to content

PDF Writers and Excel Headers #2758

Answered by kylejtuck
kylejtuck asked this question in Q&A
Discussion options

You must be logged in to vote

Well, I hate giving up on something, so for those looking for a potential solution...

<?php
require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use PhpOffice\PhpSpreadsheet\Spreadsheet;

// convert the Excel file to PDF without headers
$pdf_path = '/tmp/doc.pdf';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('excel_file.xlsx');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Mpdf');
$writer->writeAllSheets();
$writer->save($pdf_path);

// create new Mpdf objects to detect page orientation, import the above pdf file, add the header, and export
$mpdf = new \Mpdf\Mpdf();
$outpdf = new …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kylejtuck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants