数据写入excel方法小结
方法一:自定义函数1(向表中增加数据)
该方法主要用在向excel的表格中增加数据时
首先定义worksheet的行列
def chr_col(col,number):
if col < 26:
wsCol = chr((col+number) % 26 + 65) #求余+65 返回excel对应的列名
else:
wsCol = chr(int((col+number) / 26) + 64) + chr(col % 26 + 65)
return wsCol
之后将数据写入
def report_writer(result, ws,number,row_number):
"""
:param result: 需写入工作表的数据,dataFrame
:param ws: worksheet
:param number: 从第几列开始
:param row_number: 从第几行开始
"""
for ind in range