# -*- coding = utf-8 -*-
# @Time : 23:47
# @Author : kashey
# @File : excel.py
# @Software : PyCharm
import openpyxl
import docx
#import rgbcolors
# from openpyxl import load_workbook
wb=openpyxl.load_workbook(r'C:\Users\16537\Desktop\Exceltest.xlsx')
# 获取活跃表对象
sheet = wb.active
a1=sheet.cell(row=2,column=6);
# 获取单元格对应的 Cell 对象
# print(a1.value);
path = r"C:\Users\16537\Desktop\题库.docx"
word = docx.Document(path)
# 设置文档的基础字体中文
word.styles['Normal'].font.name = u'宋体'
# for i in range(0,322):
for i in range(2, 369):
id = sheet.cell(row=i, column=2).value
qus= sheet.cell(row=i, column=6).value
chosA=sheet.cell(row=i, column=7).value
chosB=sheet.cell(row=i, column=8).value
chosC=sheet.cell(row=i, column=9).value
chosD=sheet.cell(row=i, column=10).value
chosE = sheet.cell(row=i, column=11).value
ans=sheet.cell(row=i, column=12).value
p = word.add_paragraph()
str_qus='{}.{}\n'.format(id,qus)
str_chos='{}
Python excel提取表格信息整理到word中
最新推荐文章于 2023-08-16 11:54:52 发布


4151

被折叠的 条评论
为什么被折叠?



