An existing Excel Column,row,index is the first of several sheet for content modification
def writetoexcel (Index,column, modify content):
Path = paths + name.xlsx
RB =xlrd.open_workbook (PATH)
WB = Copy (RB)
S=wb.get_sheet (Index)
S.write (column+1,row+1, modify) #row行号, column number:
Wb.save (PATH)
Code:
#进行excel字体大小进行修改
#coding: Utf-8
Import XLWT;
Import xlrd;
from xlutils.copy import copy;
data = Xlrd.open_workbook (R ' D:\Letter7.xls ', formatting_info=true) #formatting_info复制单元格格式
w = copy (data)
For I in range (Len (Data.sheet_names ())):
Sheet1 = Data.sheet_by_index (i)
Sheet_data = Sheet1.cell (8, 8). Value # (line number-1, column number-1). Value takes cell contents
Data_li = Sheet_data.split ('_')
Item = Data_li.pop (-1)
Data_li.insert (0, item)
Print (Data_li)
Data_str = ' _ '. Join (Data_li)
Print (DATA_STR)
style = XLWT. Xfstyle ()
Font = XLWT. Font ()
Font.height = 0X00DC #220: Font size *20 turn 16 binary
Font.Name = ' song Body '
Style.font = Font
W.get_sheet (i). Write (8,8,data_str,style)
W.save (' D:\Letter8.xls ')
Python modifies the existing table content, formatting