Closed AzzaAzza69 closed 1 year ago
Having generated an xlsx from code (mimetype detected as application/zip) and also creating one in Excel (mimetype detected as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), writing the files in this order will fix it:
$zip->addFromString("[Content_Types].xml" , self::buildContentTypesXML() ); $zip->addEmptyDir("_rels/"); $zip->addFromString("_rels/.rels", self::buildRelationshipsXML()); $zip->addEmptyDir("xl/"); $zip->addFromString("xl/workbook.xml" , self::buildWorkbookXML() ); $zip->addEmptyDir("xl/_rels/"); $zip->addFromString("xl/_rels/workbook.xml.rels", self::buildWorkbookRelsXML() ); $zip->addEmptyDir("xl/worksheets/"); foreach($this->sheets as $sheet) { $zip->addFile($sheet->filename, "xl/worksheets/".$sheet->xmlname ); } $zip->addFile($this->writeStylesXML(), "xl/styles.xml" ); //$zip->addFromString("xl/styles.xml" , self::buildStylesXML() ); $zip->addEmptyDir("docProps/"); $zip->addFromString("docProps/core.xml", self::buildCoreXML()); $zip->addFromString("docProps/app.xml" , self::buildAppXML() );
Having generated an xlsx from code (mimetype detected as application/zip) and also creating one in Excel (mimetype detected as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), writing the files in this order will fix it: