使用Spreadsheet Excel Writer php设置Excel单元格中特定单词的颜色


Set the color for a specific word in a Excel cell using Spreadsheet Excel Writer php

我试图使用Spreadsheet_Excel_Writer在单元格中设置特定单词的颜色,但在文档中没有找到任何方法。

我必须为单元格的第一个单词设置红色,但不是为其中的整个文本设置红色。

是否有办法做到这一点与Spreadsheet_Excel_Writer?

XMLSS规范允许使用标记,可以使用标记更改字体的颜色。见http://msdn.microsoft.com/en-us/library/aa140066 (v = office.10) . aspx # odc_xmlss_ss:数据

在这种情况下,Spreadsheet_Excel_Writer将不适合您,但是如果您想将文档保存为XML,那么您可以按照下面的示例将第一个单词包装在字体标记中。

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <ss:Worksheet ss:Name="Sheet1">
  <Table>
   <Column/>
   <Row>
    <Cell>
     <ss:Data xmlns="http://www.w3.org/TR/REC-html40" ss:Type="String">
      <Font html:Color="#00ff00">green</Font>
      <Font html:Size="48" html:Color="#ff0000">red</Font>
      <Font html:Color="#0000ff">blue</Font>
     </ss:Data>
    </Cell>
   </Row>
  </Table>
 </ss:Worksheet>
</Workbook>

请注意,这是XML而不是HTML,所以它们必须是良好的格式。

您可以使用内联CSS设置任何行或列的颜色风格= "背景"