简体   繁体   English

如何使用Python从Excel复制并粘贴为Word中的图像?

[英]How to copy from Excel and paste as image in Word using Python?

How do I copy a set of cells from Excel and paste them as image in Word using Python ? 如何使用Excel复制一组单元格并将其粘贴为Word中的图像?

I am trying to automate some reports (in docx format). 我正在尝试自动化一些报告(docx格式)。 The excels are auto generated and then I have to manually copy cells from Excel and paste as image in Word. excel是自动生成的,然后我必须手动从Excel复制单元格并将其粘贴为Word中的图像。

I have done some research and found there are some libraries like python-docx (for word) and openpyxl (for excel). 我进行了一些研究,发现有一些库,例如python-docx(用于word)和openpyxl(用于excel)。 What I am not able to figure out is the copy and paste as image from excel to word. 我不知道是从excel到Word的复制和粘贴图像。

I don't think this is an easy task. 我认为这不是一件容易的事。 Because conversion Excel to image probably means the Python package/codes need to know how to render the excel content, which is a big step beyond read/write excel format. 由于将Excel转换为图像可能意味着Python程序包/代码需要知道如何呈现excel内容,这是读写excel格式之外的一大步。 I don't know any Python package can do that. 我不知道任何Python包都能做到这一点。

Assume you're running Python codes in Windows, you may try to call COM to copy/paste directly from Excel to Word. 假设您在Windows中运行Python代码,则可以尝试调用COM将Excel直接复制/粘贴到Word。 I guess that would behave just like you manually Ctrl+C/V. 我想那会像您手动按Ctrl + C / V一样。 Reference 参考

If you prefer to convert to an image, may try a VBA script. 如果您希望转换为图像,可以尝试使用VBA脚本。 Reference 参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用python将数据从excel复制并粘贴到另一个excel - How to copy and paste data from excel to another excel using python 如何使用python从excel复制图表并将其作为图表粘贴到powerpoint(不是图像)中 - How to copy chart from excel and paste it as chart into powerpoint (not image) using python 如何使用python将excel表格粘贴到word中 - How to paste excel table into word using python 如何自动从 excel 复制数据并粘贴到单词中? - How can I automaticallly copy data from excel and paste into a word? 使用Python复制并粘贴到Excel中 - Copy and paste in Excel using Python 如何使用 Python 将文本文件复制并粘贴到指定的 Excel TAB 中? - How to copy and paste text file into a specified Excel TAB using Python? 如何使用 Python 从 Words (.docx) 复制段落(带数字格式)和图像并粘贴到 Excel (.xlsx) - How to copy paragraphs (with number formatting) and images from Words (.docx) and paste into Excel (.xlsx) using Python 如何使用Python从Excel文件复制范围并将其粘贴到Powerpoint幻灯片中? - How to copy a range from an Excel File and paste that range into a Powerpoint slide using Python? 如何使用 Python 将每个 Excel 工作表中的数据复制并粘贴到最终工作表中? - How to copy and paste data from each excel sheet into a final sheet using Python? 在 Excel 中阻止复制粘贴选项,使用 python - Block copy paste option in Excel, using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM