abap2xlsx
abap2xlsx copied to clipboard
Column width optimization doesn't work without calling "calculate_column_widths"
In former versions (I can't tell exactly, it seems to have been installed in 2014) of abap2xlsx it used to work calling "set_auto_size" on the object "ColumnDimension":
In newer version (installed in november 22) column optimization has to be done on a column object e. g. by using a column iterator.
But in comparison to the former version, column width optimization does not work without explicitly calling "calculate_column_widths" (worksheet object).
I also checked some example programs e. g. ZDEMO_TECHED9. "calculate_column_widths" is not called within this program and as a result the generated Excel file doesn't have optimized columns.
In my opinion "calculate_column_widths" should be called internally before generating an Excel file if at least one column has the autosize property set.
Yes this feature was changed few years ago, I can't say how it was working before that change, what was done and why, so I trust you. Do you think you can propose a fix/pull request? Thank you.
NB: there is this discussion how it works now, especially code and demo program (in my comment): #646
Unfortunately I can't support at the moment due to our infrastructure. I don't e. g. have a connection to github via abapGit. Currently I'm also not that familiar with abab2xlsx and I don't know your deploying process (how to test ...). If I could get some help, maybe I'm able to contribute in the future ...
Thanks, no problem, just asking for help :) If in the future you have the possibility to contribute, we'll try to help our best.
I ran into the same problem
doing following works,
DO lo_worksheet->get_highest_column( ) TIMES.
lo_worksheet->get_column( zcl_excel_common=>convert_column2alpha( sy-index ) )->set_auto_size( abap_true ).
ENDDO.
lo_worksheet->calculate_column_widths( ).