Skip to content
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

feat(python): Write data at table level in write_excel #17757

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3188,6 +3188,7 @@ def write_excel(
*table_start,
*table_finish,
{
"data": df.rows(),
"style": table_style,
"columns": table_columns,
"header_row": include_header,
Expand All @@ -3198,18 +3199,6 @@ def write_excel(
},
)

# write data into the table range, column-wise
if not is_empty:
column_start = [table_start[0] + int(include_header), table_start[1]]
for c in df.columns:
if c in self.columns:
ws.write_column(
*column_start,
data=df[c].to_list(),
cell_format=column_formats.get(c),
)
column_start[1] += 1

# apply conditional formats
if conditional_formats:
_xl_apply_conditional_formats(
Expand Down Expand Up @@ -3244,8 +3233,6 @@ def write_excel(
None,
options,
)
elif options:
ws.set_column(col_idx, col_idx, None, None, options)

# finally, inject any sparklines into the table
for column, params in (sparklines or {}).items():
Expand Down