Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xlsxwriter - grouping via set_row()

I tried to set some groups in xlsxwriter but it seems I can't get the + Symbol at the top of my group. As it is setting the grouping row-wise I tried to write a function that takes the workbook, the worksheet index and a start/end as well as the level. But whatever I do the grouping symbol in excel never appears in the first row. Funny thing is, if I use something like start_row + 5 for the collapsing row I will get a second + at the right row, but still another one at the end. Does anyone know if its possible?

The examples show grouping just for the last row of a group.

def set_group(out_wb, ws_index, start_row, end_row, level):
  #added as i used an offset
  start_row = start_row
  end_row = end_row

  out_wb.worksheets()[ws_index].set_row(start_row, None, None, {'level': level, 'collapsed': True})
  for i in range(start_row + 1, end_row):
    out_wb.worksheets()[ws_index].set_row(i, None, None, {'level': level, 'hidden': True})


return out_wb
like image 377
Jan Strohschein Avatar asked Jan 17 '26 02:01

Jan Strohschein


1 Answers

You can use the outline_settings() worksheet method and set symbols_below to False:

worksheet.outline_settings(symbols_below=False)
like image 51
jmcnamara Avatar answered Jan 19 '26 18:01

jmcnamara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!