[英]How to read multiple excel sheet using python
I have an excel sheet which has multiple tables in it.我有一张 excel 表,里面有多个表。 My problem is read excel file from url then convert and save to.pdf format.我的问题是从 url 读取 excel 文件,然后转换并保存为 .pdf 格式。 Now im using pandas and matplotlib for solve my problem.现在我使用 pandas 和 matplotlib 来解决我的问题。 But now I can read only the first sheet.但现在我只能阅读第一页。 So my question is How to read multiple sheet Any pointers on this would be helpful.所以我的问题是如何阅读多张纸关于这方面的任何指示都会有所帮助。
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
url = "https://exceltesting.xlsx"
df = pd.read_excel(url)
# df = pd.read_excel(url, sheet_name=['Technologies','Schedule'])
fig, ax = plt.subplots(figsize=(12, 4))
ax.axis('tight')
ax.axis('off')
the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center')
pp = PdfPages("1.pdf")
pp.savefig(fig, bbox_inches='tight')
pp.close()
try to use df = pd.read_excel(url, sheet_name = 1)
for second sheet for example:)例如,尝试将df = pd.read_excel(url, sheet_name = 1)
用于第二张纸:)
you can then do a for loop of the sheets to produce them as a pdf with corresponding sheet:)然后,您可以对工作表进行 for 循环,以将它们生成为带有相应工作表的 pdf:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.