1

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()

1 Answer 1

1

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 :)

Sign up to request clarification or add additional context in comments.

3 Comments

did the answer solve the problem? if so, accept the anwser as correct
Thank you for your response , excel sheet reading issue solved. But when I create the loop condition, now i can only save the last sheet . how to save all sheets in 1 pdf file
maybe this anwser will help : stackoverflow.com/a/38128675/9998989

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.