Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column width optimization doesn't work without calling "calculate_column_widths" #1095

Open
blackmail24 opened this issue Mar 21, 2023 · 5 comments

Comments

@blackmail24
Copy link

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":
1

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).
2

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.

@sandraros
Copy link
Collaborator

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.

@sandraros
Copy link
Collaborator

NB: there is this discussion how it works now, especially code and demo program (in my comment): #646

@blackmail24
Copy link
Author

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 ...

@sandraros
Copy link
Collaborator

Thanks, no problem, just asking for help :) If in the future you have the possibility to contribute, we'll try to help our best.

@larshp
Copy link
Member

larshp commented Dec 12, 2023

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( ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants