mbleron / ExcelGen

ExcelGen is an Oracle PL/SQL utility to create MS Excel files (.xlsx, .xlsb)
MIT License
43 stars 9 forks source link

Column autofit #49

Open BorjaRRR opened 1 year ago

BorjaRRR commented 1 year ago

Can i do column autofit?

mbleron commented 1 year ago

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.

BorjaRRR commented 1 year ago

Ok I understand. Excellent work, by the way.

wickyhu commented 9 months ago

@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