Skip to content

ERR: better error message on too large excel sheet #26080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 1, 2019
8 changes: 4 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,13 +2149,13 @@ def to_excel(self, excel_writer, sheet_name="Sheet1", na_rep="",

df = self if isinstance(self, ABCDataFrame) else self.to_frame()

max_rows = 2**20
max_cols = 2**14
excel_max_rows = 2**20
excel_max_cols = 2**14
num_rows, num_cols = df.shape
if num_rows > max_rows or num_cols > max_cols:
if num_rows > excel_max_rows or num_cols > excel_max_cols:
raise ValueError(f"This sheet is too large! Your sheet size is: "
f"{(num_rows, num_cols)}. "
f"Max sheet size is: {(max_rows, max_cols)}.")
f"Max sheet size is: {(excel_max_rows, excel_max_cols)}.")

from pandas.io.formats.excel import ExcelFormatter
formatter = ExcelFormatter(df, na_rep=na_rep, cols=columns,
Expand Down