Home > Back-end >  How to read multiple excel sheet using python
How to read multiple excel sheet using python

Time:06-22

I have an excel sheet which has multiple tables in it. My problem is read excel file from url then convert and save to .pdf format. Now im using pandas and matplotlib for solve my problem. 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()

CodePudding user response:

try to use df = pd.read_excel(url, sheet_name = 1) for second sheet for example :)

you can then do a for loop of the sheets to produce them as a pdf with corresponding sheet :)

  • Related