for my project I'm using PHPSpreadsheet for exporting data in Excel and PDF format. If from the website, when I press on the respective download buttons, I can easily download the .xlsx and .pdf files, I have problems with the app (iOs Swift language). In fact, when I try to download the files, I receive the following messages:
- for Excel files: "the file may be damaged"
- for PDF files (I open it with Chrome): "Chrome does not support this link file: ///var/mobile/Containers/Data/Application/.../Documents/name_file.pdf"
Here are the fragments of the PHP code that deal with the download:
PDF:
$ output. = '... html code';
$ mpdf = new \ Mpdf \ Mpdf ();
$ mpdf-> Bookmark ('Start of the document');
$ Mpdf-> WriteHTML ($ output);
$ mpdf-> Output ($ filename.'. pdf',
\Mpdf\Output\Destination::DOWNLOAD);
EXCEL:
$spreadsheet = new Spreadsheet(); /*----Spreadsheet object-----*/
$Excel_writer = new Xlsx($spreadsheet); /*----- Excel (Xls) Object*/
/* ...riempiendo foglio excel con i dati */
header('Content-Type: application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet');
header('Content-Disposition:
attachment;filename="'.$filename.'.xlsx"');
header('Cache-Control: max-age=0');
$Excel_writer->save('php://output');
Thanks for your help!