设置Excel(Xml)列宽

时间:2016-10-11 09:58:30

标签: php xml excel

我是用PHP编程创建Excel文件的。

我正在努力设置列宽和行高,ss:列中的Width =“120”只是被忽略了! 以下代码取自Microsoft blog page

<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">\n
<ss:Styles>\n
    <ss:Style ss:ID="1">\n
        <ss:Font ss:Bold="1"/>\n
    </ss:Style>\n
</ss:Styles>\n
<ss:Worksheet ss:Name="Sheet1">\n
    <ss:Table>\n
        <ss:Column ss:Width="120"/>\n
        <ss:Column ss:Width="80"/>\n
        <ss:Column ss:Width="120"/>\n
        <ss:Row ss:StyleID="1">
            <ss:Cell ss:Height="25">\n
               <ss:Data ss:Type="String">First Name</ss:Data>\n
            </ss:Cell>\n
            <ss:Cell>\n
               <ss:Data ss:Type="String">Last Name</ss:Data>\n
            </ss:Cell>\n
            <ss:Cell>\n
               <ss:Data ss:Type="String">Phone Number</ss:Data>\n
            </ss:Cell>\n
        </ss:Row>\n
        <ss:Row>\n
            <ss:Cell>\n
               <ss:Data ss:Type="String">Nancy</ss:Data>\n
            </ss:Cell>\n
            <ss:Cell>\n
               <ss:Data ss:Type="String">Davolio</ss:Data>\n
            </ss:Cell>\n
            <ss:Cell>\n
               <ss:Data ss:Type="String">(206)555-9857</ss:Data>\n
            </ss:Cell>\n
        </ss:Row>\n
    </ss:Table>\n
</ss:Worksheet>\n
</ss:Workbook>\n

标题是

header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding);
header('Content-Disposition: attachment; filename="test.xls"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0,pre-check=0');
header('Pragma: public');

我实现了我想要的所有风格,除了宽度和不太重要的高度

我在Ubuntu上使用LibreOffice来查看结果

0 个答案:

没有答案