【发布时间】:2011-12-05 13:13:48
【问题描述】:
我有一个带有示例数据的 Excel (xls) 模板。我需要准备一个包含动态生成数据的 Excel 文件。
首先,我从相应的 xls 制作了一个 XML 文件。 XML 文件如下所示:
<?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>Op</Author>
<LastAuthor>ufoq</LastAuthor>
<Created>2011-11-18T06:54:25Z</Created>
<LastSaved>2011-12-05T11:43:26Z</LastSaved>
<Version>11.9999</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9750</WindowHeight>
<WindowWidth>23310</WindowWidth>
<WindowTopX>480</WindowTopX>
<WindowTopY>405</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font x:CharSet="238" x:Family="Swiss" ss:Size="8" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
......
现在我将这个内容放在 symfony 视图中,并用我生成的数据填充它。 我需要以 XML 文件格式输出,但我不知道该怎么做。 新文件必须与模板文件具有相同的结构,因此我无法从头开始创建新文件。
【问题讨论】: