[英]Adding new text into excel cell with another format using python & xlsxwriter
我認為 GetCharacters function 在 Range 上完成,使用 win32com (pywincom) 會做你想做的事。
ws.Range(cell/range as string).GetCharacters(start,end).Font.Color = [color ID]
打開工作簿后,我可以將字符 2-5 設為紅色:
ws.Range('A1').GetCharacters(2,5).Font.Color = -16776961
我從上一個關於加粗的問題中得到了很多這樣的信息: How Do I Bold only part of a string in an excel cell with python
為了獲得顏色(並且可能有更好的方法),我進入 Excel 並使用宏記錄,並將字體更改為紅色,然后看到宏記錄的那個顏色。 因此,您可以從中獲得您想要的 colors 的編號 ID。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.