XLS file created using XML format shown XML data in OpenOffice.org Calc and share on Google Drive

108 views Asked by At

I have created XLS file using XML format in php. It show perfectly in Windows excel but when I open this with OpenOffice.org Calc or share on Google Drive then it show XML data. Can somebody help me for this issue. File created using:

$html = '<?xml version="1.0"?>
                <?mso-application progid="Excel.Sheet"?>
                <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                   xmlns:o="urn:schemas-microsoft-com:office:office"
                   xmlns:x="urn:schemas-microsoft-com:office:excel"
                   xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                   xmlns:html="http://www.w3.org/TR/REC-html40">
                <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
                   <Author>TEST</Author>
                   <LastAuthor>TEST</LastAuthor>
                   <Created>TEST</Created>
                   <Version>1.00</Version>
                </DocumentProperties>
                <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
                   <WindowHeight>8250</WindowHeight>
                   <WindowWidth>21075</WindowWidth>
                   <WindowTopX>0</WindowTopX>
                   <WindowTopY>0</WindowTopY>
                   <ActiveSheet>0</ActiveSheet>
                   <ProtectStructure>False</ProtectStructure>
                   <ProtectWindows>False</ProtectWindows>
                </ExcelWorkbook>
                ' . $styleStr . '
                ' . $data . '
               </Workbook>';

    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=$file");
    echo $html;
    exit;

Where $styleStr is style string and $data is table data which is in XML format

0

There are 0 answers