- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 python 的新手(以及一般的编程)。
我在使用 xlrd
、xlwt
和 xlutils
访问 xlsx 工作簿时遇到问题(它是一个常见问题,但我没有找到适合我的解决方案)。
我应该为 py-excel
更改我的包吗?在那种情况下,哪个?
这是我的代码:
import xlrd
import xlwt
from xlutils.copy import copy as xlutils_copy
rd = xlrd.open_workbook("x:/PROJECTS/Papers/2014_Pasture/a.xlsx")
rdsh = rd.sheet_by_name("FR_PASTURE")
wrb = xlutils_copy(rd)
ws = wrb.get_sheet_by_name("FR_PASTURE")
我收到的错误:
Traceback (most recent call last):
File "X:\PROJECTS\Papers\2014_Pasture\AdjustXLSStats.py", line 28, in <module>
wrb = xlutils_copy(rd)
File "C:\Python27\lib\site-packages\xlutils-1.7.0-py2.7.egg\xlutils\copy.py", line 19, in copy
w
File "C:\Python27\lib\site-packages\xlutils-1.7.0-py2.7.egg\xlutils\filter.py", line 937, in process
reader(chain[0])
File "C:\Python27\lib\site-packages\xlutils-1.7.0-py2.7.egg\xlutils\filter.py", line 68, in __call__
filter.cell(row_x,col_x,row_x,col_x)
File "C:\Python27\lib\site-packages\xlutils-1.7.0-py2.7.egg\xlutils\filter.py", line 573, in cell
wtrow.set_cell_number(wtcolx, cell.value, style)
File "build\bdist.win-amd64\egg\xlwt\Row.py", line 203, in set_cell_number
self.__adjust_bound_col_idx(colx)
File "build\bdist.win-amd64\egg\xlwt\Row.py", line 78, in __adjust_bound_col_idx
raise ValueError("column index (%r) not an int in range(256)" % arg)
ValueError: column index (256) not an int in range(256)
安装的 xlutils 版本:1.7.0操作系统:Windows 8excel:office 20113
最佳答案
xlrd
、xlwt
和xlutils
用于访问xls 文件,尚未更新使用使用 xlsx 文件,这会导致您出现多个错误。
作为解决方法,现在有一个 Python 库 openpyxl
可以轻松读写Excel xlsx
/xlsm
/xltx
/xltm
文件。
关于python - xlutils.copy [python 2.7 - excel],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22252978/
我正在使用 Python 2.5(并且需要继续使用它)并且已经下载了 xlrd 0.8.0 和 xlwt 0.7.2,它们似乎都工作正常。 我将需要读取和写入 Excel 电子表格,因此相信我也需要添
我正在尝试使用 Python 修改 Excel 文件,但我无法让 xlutils 包正常工作。当我尝试一个示例时(来自 this 线程): from xlutils.copy import copy
所以我有一个 Excel 电子表格,其中有一个我想要对电子表格进行排序的特定列。该列有 3 种不同的起始字母组合:B、C、E。我想按 B 排序,然后按 E 排序,然后按 C 开头的所有行排序。我确实需
我有一个包含许多相同格式的 excel 文件的文件夹,其中包含多张工作表。目标是遍历文件夹并将每个笔记本中的一张工作表移动到新笔记本,即从新工作簿中的每个 .xlsx 文件中结束一张工作表。我通常使用
我有一个现有的 Excel 工作簿 Workbook_A。我正在创建一个相同的工作簿 Workbook_B,然后将一些值插入到新工作簿的某些单元格中。 我正在做的事情的简化版本: from xlrd
我正在使用 xlutils 并复制工作表。下面的代码成功复制了第一个工作表并添加了 2 个副本,但是当我写入每个工作表时,它会将更改应用于所有工作表副本以及原始工作表。 因此在下面的示例中,所有 3
我有简单的代码可以使用 xlutils、xlrd、xlwt(从 python-excel.org 下载的新库)复制文件而不丢失格式。我收到如下错误: from xlwt.Workbook import
我正在尝试写入现有的 xls 文件,然后迭代同一文件的行,直到找到空白。 我了解如何通过代码执行此操作。 现在我的问题是,xlrd 是否“更新”它对工作表的引用?或者我是否必须在每次写入时通过打开工作
它们都是用于控制 Excel 的开源 Python 包(参见 python-excel )。我仍在努力理解他们的代码。如果有人能给出提示,他们如何以低杠杆方式连接到 Excel?通过 xml、Exce
我是 python 的新手(以及一般的编程)。 我在使用 xlrd、xlwt 和 xlutils 访问 xlsx 工作簿时遇到问题(它是一个常见问题,但我没有找到适合我的解决方案)。 我应该为 py-
我只想复制整个工作簿。有一些信息需要稍后添加,我很容易找到如何将信息添加到单个单元格等......但我还没有找到复制整个工作表的方法。也许我把这个问题过于复杂化了,但任何意见都会受到赞赏。谢谢! 最佳
是否有 xlrd、xlwt 和 xlutils 的替代方案用于在 python 中处理 MS Excel?据我所知,他们的许可不允许将其用于商业目的,我想知道除了使用 COM 之外是否还有其他选择。
如何使用 xlrd、xlwt 和 xlutils 模块编辑和保存现有 Excel 工作簿中的数据?有人可以提供一个示例代码来编辑和保存Excel工作簿中的数据吗? 我正在尝试将数据从一个工作簿放入另一
如果我理解正确,工作簿的 add_sheet 方法会创建一个新工作表(并将其添加到工作簿)。我有一个现有的 excel 模板(带有一个格式化工作表作为向其添加信息的基础),我想使用 xlutils 复
这个问题在这里已经有了答案: Preserving styles using python's xlrd,xlwt, and xlutils.copy (2 个答案) 关闭 8 年前。 简而言之,我
我尝试搜索很多地方,但没有看到任何关于如何使用 xlutils 或 xlwt 和 python 删除 excel 文件中现有工作表的示例代码片段。请问谁能帮帮我? 最佳答案 我刚刚处理了这个问题,虽然
我正在使用 xlrd、xlutils.copy 和 xlwt 打开一个模板文件,复制它,用新的填充它值,然后保存。 但是,似乎没有任何简单的方法可以保留单元格的格式;它总是被吹走并设置为空白。有什么简
大家好,先谢谢大家。 我有一个 python 脚本,我在其中打开模板 excel 文件,添加数据(同时保留样式)并再次保存。我希望能够在保存新的 xls 文件之前删除我没有编辑的行。我的模板 xls
我是一名优秀的程序员,十分优秀!