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

SXSSFSheet AutoSizeColumn only considering last lines, missing call in SXSSFRow? #547

Closed
ctrlbru opened this issue May 5, 2021 · 2 comments

Comments

@ctrlbru
Copy link

ctrlbru commented May 5, 2021

Hi, I have code that works with XSSF and properly auto resizes columns. I moved on to SXSSFSheet to be able to handle bigger datasets and I can't make auto resize work.

I'm generating a sheet with 45 columns and around 250 rows. NuGet package 2.5.3. I do the following:

  • Create the sheet
  • Call TrackColumnForAutoSizing for all columns (or TrackAllColumns, doesn't matter)
  • Fill everything and set styles as needed (but the issue is independent from styles)
  • Call AutoSizeColumn on each column

The output is somehow auto sized, but it seems to only consider the last row or rows (maybe the window size). If I reorder the rows when I prepare the file, so that the widest values stays at the bottom, the columns are resized correctly.

I checked the code and I see that for SXSSFSheet the width is calculated as max between the width in the current window and the one from the already flushed rows.

I noticed that in commit 2df83be a call to _autoSizeColumnTracker.UpdateColumnWidths() was removed from SXSSFRow.flushOneRow(). In the same commit I can't see anything replacing that.

I'm looking at this source code for the first time so I might be wrong, but it seems to me that call was needed. I will try to compile and test but I'd like some comments to understand if I'm dead wrong.

@tonyqus
Copy link
Member

tonyqus commented Oct 8, 2021

Can you provide some screenshots for the cases which are not autosized correctly? I need more inputs to understand/reproduce your scenario

@tonyqus tonyqus added this to the NPOI 2.5.6 milestone Oct 8, 2021
@tonyqus tonyqus closed this as completed Feb 4, 2022
@tonyqus tonyqus modified the milestones: NPOI 2.5.6, NPOI vNext Feb 6, 2022
@tonyqus
Copy link
Member

tonyqus commented Feb 6, 2022

I've uncomment the code

_autoSizeColumnTracker.Value?.UpdateColumnWidths(firstRow);

@tonyqus tonyqus modified the milestones: NPOI vNext, NPOI 2.5.6 Feb 6, 2022
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

2 participants