3
我正尝试将内联样式应用于Excel电子表格中的单元格,以便在单个单元格中具有粗体,非粗体和不同颜色的文本。Excel XML:格式化内嵌文本
我使用了以下内容:
<Row>
<Cell ss:StyleID="s1">
<ss:Data ss:Type="String" xml:space="preserve" xlmns="http://www.w3.org/TR/REC-html40"><Font>Black text</Font><B>Bold text</B><Font html:Color="#FF0000">Red text</Font></ss:Data>
</Cell>
</Row>
不幸的是,这似乎并没有产生任何影响。当我在Excel中打开时,我的文本全部显示为黑色而不是粗体。
我完全难住,因为我相信<Font html:Color="#FF0000">Red text</Font>
和<B>Bold text</B>
是正确的元素使用。
这里是我完整的XML:
<?xml version="1.0" encoding="utf-8"?><?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>John</Author>
<LastAuthor>Smith</LastAuthor>
<LastPrinted>2013-11-13T12:16:09Z</LastPrinted>
<Created>2011-10-05T11:29:15Z</Created>
<LastSaved>2014-02-03T15:36:18Z</LastSaved>
<Company>Microsoft</Company>
<Version>14.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9096</WindowHeight>
<WindowWidth>22980</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>252</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" ss:ID="s1">
<Alignment ss:Vertical="Top" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font xmlns:x="urn:schemas-microsoft-com:office:excel" ss:FontName="Calibri" x:Family="Swiss" ss:Size="11"/>
</Style>
</Styles>
<Worksheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" ss:Name="PDA Printout">
<Table xmlns:x="urn:schemas-microsoft-com:office:excel">
<Column ss:Width="500"/>
<Row>
<Cell ss:StyleID="s1">
<ss:Data ss:Type="String" xml:space="preserve" xlmns="http://www.w3.org/TR/REC-html40"><Font>Black text</Font><B>Bold text</B><Font Color="#FF0000">Red text</Font></ss:Data>
</Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
谢谢你的评论,但我可以证实,Excel的**做单个细胞内**支持多种样式。 这可以通过创建一个新的Excel文件,在单个单元格中应用多种样式,然后另存为XML Spreadsheet 2003来证明。 –
@CraigJohnstone嘿,你是对的。我会删除这个错误的答案,并试图明白为什么它不适合你。 – David
@CraigJohnstone更改了答案。请尝试。我只是保存了一个格式不同的文件,并复制了它们之间的差异。 :) – David