2
是否可以使用熊貓的Excel作家設置字體名稱?熊貓`to_excel`設置字體名稱
這裏是我的嘗試:
import pandas as pd
from pandas.io.excel import ExcelWriter
df = pd.DataFrame([[1,2,3],[4,5,6]])
writer = ExcelWriter("test.xlsx")
writer.set_font_name("Arial") # this would be ideal, but no such method exists
format = writer.book.add_format({"font_name": "Arial"})
df.to_excel(writer) # format is not applied. Need to pass `format` object somewhere
writer.close()
我在哪裏可以傳遞xlsxwriter.format.Format
對象一旦被創造出來的?
這幾乎是完美的:它的工作原理,但在所有的標題樣式:我仍然得到默認的大熊貓大膽宋體,甚至與線你建議('pd.formats.format.header_style = None')。我還試圖在創建編寫器之前定義標題樣式,但我仍然得到相同的結果。 – gozzilli
@gozzilli,它適合我。你的Pandas版本是什麼? – MaxU
0.19.2在MacOSX上 – gozzilli