Python excel提取表格信息整理到word中
# -*- coding = utf-8 -*-
# @Time : 23:47
# @Author : kashey
# @File : excel.py
# @Software : PyCharmimport 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).valuequs= sheet.cell(row=i, column=6).valuechosA=sheet.cell(row=i, column=7).valuechosB=sheet.cell(row=i, column=8).valuechosC=sheet.cell(row=i, column=9).valuechosD=sheet.cell(row=i, column=10).valuechosE = sheet.cell(row=i, column=11).valueans=sheet.cell(row=i, column=12).valuep = word.add_paragraph()str_qus='{}.{}\n'.format(id,qus)str_chos='{}\n{}\n{}\n{}\n{}\n'.format(chosA,chosB,chosC,chosD,chosE)str_ans='答案:{}\n'.format(ans)run_qus=p.add_run(str_qus)run_chos=p.add_run(str_chos)run_ans=p.add_run(str_ans)run_qus.font.color.rgb = docx.shared.RGBColor(0, 0, 255)run_chos.font.color.rgb = docx.shared.RGBColor(0, 0, 0)run_ans.font.color.rgb = docx.shared.RGBColor(255, 0, 0)for i in range(437, 511):id = sheet.cell(row=i, column=2).valuequs= sheet.cell(row=i, column=6).valueans=sheet.cell(row=i, column=12).valuep = word.add_paragraph()str_qus='{}.{}:\n'.format(id,qus)# str_chos='{}\n{}\n{}\n{}\n{}\n'.format(chosA,chosB,chosC,chosD,chosE)str_ans='答案:{}\n'.format(ans)run_qus=p.add_run(str_qus)#run_chos=p.add_run(str_chos)run_ans=p.add_run(str_ans)run_qus.font.color.rgb = docx.shared.RGBColor(0, 0, 255)#run_chos.font.color.rgb = docx.shared.RGBColor(0, 0, 0)run_ans.font.color.rgb = docx.shared.RGBColor(255, 0, 0)word.save(r'C:\Users\16537\Desktop\这是测试.docx')
Python excel提取表格信息整理到word中相关推荐
- 从 pdf 中提取表格信息、合并、解析、输出数据
从 pdf 中提取表格信息.合并.解析.输出 pdf 格式浅述 word 文档 与 pdf pdf 文档撰写的优点与难点 从 pdf 中抽取表格所在的页 从 pdf 中抽取表格 合并表格.解析表格.生 ...
- java 操作 word 表格和样式,java读取word表格中的表格 java如何读取word中的excel表格数据...
Java 利用poi 可以直接读取word中的表格保持样式生1.读取word 2003及word 2007需要的jar包 读取 2003 版本(.doc)的word文件相对来说比较简单,只需要 poi ...
- 怎样快速将excel表格内容转换到word中
处理各种表格数据基本都是用excel表格来操作的.一些情况下需要将表格内容转成word文档格式中查看的时候,很多都是直接用复制粘贴的方法,来将表格内容转到word中.如何表格内容太大,复制起来也是很麻 ...
- python Excel数据表格转为HTML网页数据表格
python Excel数据表格转为HTML网页数据表格 文章目录 准备test数据 Excel转html 准备test数据 首先,准备一个excel.以以下代码为例,在当前目录下生成一个Excel文 ...
- python使用logging打印信息到日志文件中
python使用logging打印信息到日志文件中 参考 Python输出日志信息 Python + logging 输出到屏幕,将log日志写入文件 使用logging打印日志到文件中的目的是: 解 ...
- Excel提取超链接信息
在Excel文档中,可能会存在多条超链接,默认情况下只有将鼠标放置在超链接上才能看到地址信息.如果想要提取该地址信息,可以按如下方法进行操作. 打开Excel文档,按"Alt+F11&quo ...
- python 将pdf分页后插入至word中
所用技术 1. python编程基础 2. 使用pyPdf 3. 使用python操作word 4. 正则表达式的使用 5. windows的bat编程 下面是一个pyPdf库使用的示例: from ...
- 删除word中所有的表格_如何在Word中删除表格
删除word中所有的表格 If you've inserted a table in Word and you now want to delete it, you may have found it ...
- 分享个人收集或整理的word中常用的vba代码
在word中通过VBA编写一些常用的函数,再利用快捷键激发,可以有效的提高写作的效率.以下分享个人通过网络收集,或者改造,或者自己录制后修改的代码,有需要的可以自取. 因为已经记不清有些代码的出处了, ...
最新文章
- 最小二乘法、迭代优化、坐标轴下降法(Coordinate Descent, CD)、坐标下降和梯度下降对比、梯度下降法/最速下降法
- leetcode算法题--Unique Paths II
- 项目杂记——在后台获取Repeater控件里面的控件
- 转发萌新人鱼博客-Java面向对象-面向对象编程之基本概念
- kmeans python自定义初始聚类中心_机器学习-KMeans聚类 K值以及初始类簇中心点的选取...
- 51. yii csrf
- SharePoint 2013 母版页修改后,无法添加应用程序
- (黑苹果efi文件)B550-I Ryzen 9 5950X RX 5700 XT 黑苹果efi引导文件
- 小程序服务器新消息通知,如何在手机上实时接收微信小程序客服消息提醒?
- 基于yolov3 v4 v5的电梯轿厢下的电动车目标检测
- basler恢复出厂设置_bios恢复出厂设置
- 知识共享,让企业“活”起来
- pythonsze_python学习笔记二 数据类型(基础篇)
- React通过后台图片路径,打包下载图片
- SynchronizedMonitor总结
- 网站页面静态化(一)初识
- 设置Win7虚拟机的内存
- HDU 4509 湫湫系列故事——减肥记II
- python非可选参数_带plac的可选参数的默认值和非默认值 - python
- search engin学习笔记1
热门文章
- 报表控件ActiveReports快速入门指南 - 如何为报表创建、添加数据
- 和阿文一起学H5——H5工具、素材
- linux shell 看门狗,Linux 下如何使用看门狗
- windows 2008/2012(64位) IIS配置asp程序 500 - 内部服务器错误。您查找的资源存在问题,因而无法显示。
- 低代码!数字时代新的 Excel / PPT ?
- mac的照片应用照片原图存储位置
- html实现信封效果,css信封边框效果实现的2种方法
- 模块电路选型(2)----主控模块
- stem课程是什么意思
- 运行BOA报错 Could not open mime.types file, /etc/mime.types, for reading