Closed adiakeka closed 1 year ago
@adiakeka I got the same problem, without Code Igniter. The XLSX is basically a ZIP file, all XML files in it have no newline in my case. Where did you see the empty new line? I would like to patch the library, to get rid of the problem.
I have the same problem using xlsxwriterplus (using AddImage()) and not using xlsxwriter. WriteToFile and Finalize functions in the two libraries, are a bit different....
Same issue here
You can use my class which extend Response (DownloadResponse) class from CI4 and it should solve yours issues https://github.com/awiater/emporico/blob/main/DownloadResponse.php
maybe set display_errors to Off in your php.ini ?
I'm trying to integrate [PHP_XLSXWriter] (https://github.com/mk-j/PHP_XLSXWriter) with Code Igniter
Here's my controller source code
`public function ToExcel(){ include_once APPPATH.'/third_party/xlsxwriter.class.php'; $filename = "report-".date('d-m-Y-H-i-s').".xlsx"; header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"'); header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate'); header('Pragma: public');
}`
The Excel file are generated and downloaded successfully, but when I try to open it using Ms Excel, it says that the file was corrupted. The problem is, it turned out that there's an empty single line at first row of the generated Excel file
When I delete that empty line, it can be opened without any problem
And also, if I copy that controller code to single php file (without Code Igniter involved), the script and generated Excel file worked like a charm
How do I get rid of that first empty line?
Many thanks for the help