ExcelGen icon indicating copy to clipboard operation
ExcelGen copied to clipboard

Column autofit

Open BorjaRRR opened this issue 2 years ago • 3 comments

Can i do column autofit?

BorjaRRR avatar Jul 31 '23 13:07 BorjaRRR

It's not possible at the moment. The best you can do is set column width individually via setColumnProperties.

Note that Autofit is a complex operation, requiring the knowledge of font metrics, and building the whole dataset in memory in order to compute the max string size for each column.

I'll keep this issue open as an enhancement. I may implement something for the default font in the future.

mbleron avatar Jul 31 '23 19:07 mbleron

Ok I understand. Excellent work, by the way.

BorjaRRR avatar Aug 01 '23 09:08 BorjaRRR

@mbleron Hi, how about to consider a setting of default column width, by column type (and width maybe)?

Below just a simple rough thought for example:

  1. char/varchar related: if column data length<=50 then C1 else C2
  2. date/timestamp: default to D
  3. numeric related: if value <= 10000000 then N1 else N2
  4. others: default to O

I think a kind of default column width setting may meet 90% cases, then we can set specific column width by setColumnProperties only when it's needed.

Regards Wicky

wickyhu avatar Dec 15 '23 00:12 wickyhu