2015-09-06 69 views
0
ws.cell(row=greenBegin+1, column=3).style.fill.fill_type = 'solid' 

    ws.cell(row=greenBegin+1, column=3).style.fill.start_color.index = '0000FF' 

    ws.cell(row=greenBegin+1, column=3).style.fill.end_color.index = '0000FF' 

我試圖設置使用此代碼穩定的綠色單元格的填充,但我總是得到「AttributeError錯誤:無法設置屬性」當我運行的代碼。我嘗試過不同的造型方法,但是關於這個庫AFAIK並沒有太多的信息,因爲我用它來做一個工作項目,這至少是很麻煩的。OpenPyXL:AttributeError的嘗試時設置填充

+1

我不使用Python,但快速搜索產生[這](http://stackoverflow.com/questions/30484220/python-fill-cells-with-colors- using-openpyxl)希望這有助於? –

+1

另一[ONE](http://stackoverflow.com/questions/30904765/how-do-i-color-fill-in-a-specific-excel-cell-using-openpyxl) –

+1

或[THIS](http: //stackoverflow.com/questions/8440284/setting-styles-in-openpyxl) –

回答

-1

這包括在文檔中。樣式是不可改變的,因此不能在原位進行編輯。他們必須重新分配。

http://openpyxl.readthedocs.org/en/2.3.0-b1/styles.html

ws.cell(…).fill = Fill(…)

+1

我已經在我的第一條評論中鏈接了您的答案。用輕微的變化重新發布相同的答案是沒有意義的。 –

相關問題