Python modifies the existing table content, formatting

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.