Bootstrap

python写入excel表格_Python如何使用ExcelWriter写入现有工作表

1586010002-jmsa.png

I am trying to use ExcelWriter to write/add some information into a workbook that contains multiple sheets.

First time when I use the function, I am creating the workbook with some data. In the second call, I would like to add some information into the workbook in different locations into all sheets.

def Out_Excel(file_name,C,col):

writer = pd.ExcelWriter(file_name,engine='xlsxwriter')

for tab in tabs: # tabs here is provided from a different function that I did not write here to keep it simple and clean

df = DataFrame(C) # the data is different for different sheets but I keep it simple in this case

df.to_excel(writer,sheet_name = tab, startcol = 0 + col, startrow = 0)

writer.save()

In the main code I call this function twice with different col to print out my data in d

;