I am trying to set the color for a specific word in a cell using Spreadsheet_Excel_Writer but did not found any way in the documentation.
我正在尝试使用Spreadsheet_Excel_Writer为单元格中的特定单词设置颜色,但在文档中没有找到任何方法。
I have to set the red color for the first word of a cell but not for the whole text in it.
我必须为单元格的第一个单词设置红色,而不是为其中的整个文本设置红色。
Is there a way to do this with Spreadsheet_Excel_Writer?
有没有办法用Spreadsheet_Excel_Writer做到这一点?
2 个解决方案
#1
1
The XMLSS spec allows you to use tags, which you can use to change the colour of the font. See http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:data
XMLSS规范允许您使用标记,您可以使用它来更改字体的颜色。请参阅http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:data
Spreadsheet_Excel_Writer won't work for you in this case, however if you want to save the document as XML, you can then wrap your first word in a font tag as per the example below.
在这种情况下,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>
Just make note that this is XML not HTML so they must be well formed.
请注意,这是XML而不是HTML,因此它们必须格式良好。
#2
0
you can set color in any row or column by using inline CSS like style="background"
您可以使用内联CSS(如style =“background”)在任何行或列中设置颜色
#1
1
The XMLSS spec allows you to use tags, which you can use to change the colour of the font. See http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:data
XMLSS规范允许您使用标记,您可以使用它来更改字体的颜色。请参阅http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:data
Spreadsheet_Excel_Writer won't work for you in this case, however if you want to save the document as XML, you can then wrap your first word in a font tag as per the example below.
在这种情况下,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>
Just make note that this is XML not HTML so they must be well formed.
请注意,这是XML而不是HTML,因此它们必须格式良好。
#2
0
you can set color in any row or column by using inline CSS like style="background"
您可以使用内联CSS(如style =“background”)在任何行或列中设置颜色