我想使用Spreadsheet_Excel_Writer設置單元格中特定單詞的顏色,但在documentation中未找到任何方法。使用電子表格Excel Writer設置Excel單元格中特定單詞的顏色php
我必須爲單元格的第一個單詞設置紅色,但不能爲其中的整個文本設置紅色。
有沒有辦法用Spreadsheet_Excel_Writer做到這一點?
我想使用Spreadsheet_Excel_Writer設置單元格中特定單詞的顏色,但在documentation中未找到任何方法。使用電子表格Excel Writer設置Excel單元格中特定單詞的顏色php
我必須爲單元格的第一個單詞設置紅色,但不能爲其中的整個文本設置紅色。
有沒有辦法用Spreadsheet_Excel_Writer做到這一點?
XMLSS規範允許您使用標籤,您可以使用它來更改字體的顏色。請參閱http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:data
在這種情況下,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像 風格=「背景」
我不認爲Spreadsheet_Excel_Writer能做到這一點,因爲我記得讀的源代碼,他們在細胞水平進行操作設置任何行或列的顏色。我認爲你應該嘗試http://phpexcel.codeplex.com/ - 它支持豐富的文本。 – XzKto
@Xzkto:謝謝,我認爲這不能使用Spreadsheet_Excel_Writer完成。將嘗試別的 –
另一個笨拙的可能性將着色兩個單元格併合並它們,如果這保持其原有的顏色。 –