File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ def render_into_sheet(
34
34
* ,
35
35
translator : Callable [[str , str ], str ] | None = None ,
36
36
offset_rows = 0 ,
37
+ autofit = True ,
38
+ table_name : str | None = None ,
37
39
) -> "Worksheet" :
38
40
try :
39
41
import polars as pl
@@ -116,21 +118,28 @@ def render_into_sheet(
116
118
ws .write (row_ind , i , value , formats [i ])
117
119
118
120
assert ws .name is not None
119
-
121
+ if not table_name :
122
+ table_name = ws .name .replace (" " , "_" )
123
+ existing_names = set (t ["name" ].lower () for t in ws .tables if t .get ("name" ))
124
+ cnt = 2
125
+ while table_name .lower () in existing_names :
126
+ table_name = ws .name .replace (" " , "_" ) + "_" + str (cnt )
127
+ cnt += 1
120
128
ws .add_table (
121
129
offset_rows ,
122
130
0 ,
123
131
row_ind ,
124
132
len (configs ) - 1 ,
125
133
{
126
- "name" : ws . name . replace ( " " , "_" ) ,
134
+ "name" : table_name ,
127
135
"style" : "Table Style Medium 2" ,
128
136
"columns" : [
129
137
{"header" : config .get_header (translator )} for config in configs
130
138
],
131
139
},
132
140
)
133
- ws .autofit ()
141
+ if autofit :
142
+ ws .autofit ()
134
143
135
144
fp = sheet_options .get ("freeze_panes" , None )
136
145
if fp :
Original file line number Diff line number Diff line change 1
1
[project ]
2
2
name = " bmsdna-table-rendering"
3
- version = " 0.3.6 "
3
+ version = " 0.3.7 "
4
4
description = " "
5
5
authors = [{ name = " Adrian Ehrsam" , email = " adrian.ehrsam@bmsuisse.ch" }]
6
6
dependencies = [
You can’t perform that action at this time.
0 commit comments