鱼C论坛

 找回密码
 立即注册
查看: 1423|回复: 2

关于openpyxl的一个问题

[复制链接]
发表于 2018-3-30 14:28:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
openpyxl除了.append()方法在表的最后一行追加内容外,能不能做到在表格的中间指定位置插入一行?查了openpyxl的文档,似乎没有发现有效的方法,还是我没找到?
例如我从前向后爬了2W条数据,这个数据源是随时会更新的,我想定期把更新的内容爬下来追加到表头(第二行),能不能用openpyxl插入行?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-3-30 14:52:37 | 显示全部楼层
你查的是什么文档。。。
Playing with data
Accessing one cell
Now we know how to access a worksheet, we can start modifying cells content.

Cells can be accessed directly as keys of the worksheet

>>> c = ws['A4']
This will return the cell at A4 or create one if it does not exist yet. Values can be directly assigned

>>> ws['A4'] = 4
There is also the openpyxl.worksheet.Worksheet.cell() method.

This provides access to cells using row and column notation:

>>> d = ws.cell(row=4, column=2, value=10)
Note

When a worksheet is created in memory, it contains no cells. They are created when first accessed.
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-3-31 19:04:46 | 显示全部楼层
大头目 发表于 2018-3-30 14:52
你查的是什么文档。。。
Playing with data
Accessing one cell

这些只是访问/修改行或单元格吧
我想做的是像列表的insert那样,在某一行之前“插入”一行,现有的的所有行向后顺移。那些例子是修改一个单元格或一行
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-12-29 00:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表