简体   繁体   English

如何打开 Excel 文件然后将值保存到 doc 或 pdf?

[英]How to open an Excel file then save values to doc or pdf?

How do I execute a script that我如何执行一个脚本

  • opens an Excel file打开一个 Excel 文件
  • searches for a value (there are many in the file so I would like to make a random copy)搜索一个值(文件中有很多,所以我想随机复制一个)
  • copies it to pdf / doc and saves将其复制到 pdf/doc 并保存
  • goes to the next Excel file and repeats the same operation (all data from Excel must be saved in one pdf / doc.转到下一个 Excel 文件并重复相同的操作(来自 Excel 的所有数据必须保存在一个 pdf / doc 中。

My Excel file structure:我的 Excel 文件结构:

价值

I want to export the data to pdf / doc for which the value is 1.我想将数据导出到值为 1 的 pdf/doc。

I started writing the code我开始写代码

import pandas as pd
import numpy as np
file_loc = "location of xlsx file"
df = pd.read_excel(file_loc, na_values=['NA'], usecols = "A:AA")
print(df)

There seem to be a package called python-docx似乎有一个名为python-docx的包

This might get you started这可能会让你开始

https://python-docx.readthedocs.io/en/latest/ https://python-docx.readthedocs.io/en/latest/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM