python - 使用python进行特殊粘贴
问题描述
我们需要从具有一些复杂格式的现有 excel 文件中进行特殊粘贴。此外,使用基于 win32 的应用程序(如 :openpyxl 或 xlwings)存在许可证限制。是否有任何替代库可以在 python 中做同样的事情?
我们尝试使用以下代码:
代码 :
wb = openpyxl.load_workbook(file_location,data_only=True)
wb.save(file_location1)
sourceFile=wb
targetFile= openpyxl.load_workbook(file_location1)
sourceSheetNames=['Overview']
for sheet in sourceSheetNames:
sourceFileActiveSheet = sourceFile[sheet]
targetFileActiveSheet = targetFile[sheet]
maxRowsourceFile = sourceFileActiveSheet.max_row
##for rowNum in range(1, maxRowsourceFile + 1):
for rowNum in range(4, 30):
for colNum in range(1, 30): # copy everything up to and including column 30
value = sourceFileActiveSheet.cell(row=rowNum, column=colNum).value
print(value)
targetFileActiveSheet.cell(row=rowNum, column=colNum).value= value
targetFile.save(file_location1)
附件中添加的excel文件快照
解决方案
推荐阅读
- c - 我什么时候应该使用动态内存分配?
- pega - 如何使用 pega 系统变量检查 SLA 规则是否已执行?
- c# - Mqtt client.connect 运行时失败
- android - Flutter Flat Button Color Property Not Working
- c++ - 如何使用 CMake 在 android 构建上编译和共享两个 c++ 库
- javascript - 开始时标签是否可能导致css和js无法加载
- amazon-cloudformation - 在 AWS 实例创建之间添加延迟
- javascript - 使用子值消除父节点
- javascript - 向下滚动时导航栏更改,如何使更改响应?
- java - 使用 Java 从共享点检索数据并对其进行处理的最佳方法是什么?