简体   繁体   English

如何使用 python 读取多个 excel 表

[英]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.

相关问题 如何使用python从文件夹中的多个excel文件中读取具有“ mine”工作表名称的工作表? 我正在使用xlrd - how to read any sheet with the sheet name containing 'mine' from multiple excel files in a folder using python? i am using xlrd 如何从 Python 中的 excel 工作表的每个选项卡中读取多个表格? - How to read multiple tables from each tab of an excel sheet in Python? 如何使用 python 从单个 excel 表中读取两个表? - How to read two tables from single excel sheet using python? 使用 Pandas 读取带有多个标题的 Excel 表格 - Read excel sheet with multiple header using Pandas 如何从多个 csv 文件中读取数据并写入 Python 中的单个 Excel 表的同一张表 - How to read data from multiple csv files and write into same sheet of single Excel Sheet in Python 当工作表有多个可能的名称时,如何将多个 Excel 工作表读入 python - How to read in multiple excel sheets into python when there is multiple possible names for a sheet 如何读取多个Excel文件并将其加载到一张Excel工作表中 - How to read multiple excel files and load into one excel sheet 如何使用 python 将一个 excel 工作表模板复制到多个 excel 文件中 - How to copy one excel sheet template into multiple excel files using python 如何使用Python合并来自不同工作簿的多个同名excel工作表并保存到新的excel工作簿中 - How to merge multiple excel sheet with the same name from different workbooks and save into a new excel workbook using Python 如何使用变量执行用户定义的python方法,请从Excel工作表中读取 - How to Execute the user defined python methods using variables, read from Excel sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM