Skip to content

Commit

Permalink
feat(python): Write data at table level in write_excel (#17757)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Beedie <alexander-beedie@users.noreply.github.com>
  • Loading branch information
mcrumiller and alexander-beedie authored Jul 25, 2024
1 parent bcb1db8 commit 3016c07
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,7 @@ def write_excel(
*table_start,
*table_finish,
{
"data": df.rows(),
"style": table_style,
"columns": table_columns,
"header_row": include_header,
Expand All @@ -3221,18 +3222,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 @@ -3267,8 +3256,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

0 comments on commit 3016c07

Please sign in to comment.