Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Fix AutoSizeColumn #97

Merged
merged 2 commits into from
Oct 11, 2018
Merged

Fix AutoSizeColumn #97

merged 2 commits into from
Oct 11, 2018

Conversation

gtbuchanan
Copy link
Contributor

Fixes #77 and part of #74.

The existing AutoSizeColumn unit tests pass now and the new calculations seem to be working great.

Unfortunately, when I reference NPOI indirectly from a net461 ASP.NET project some of the columns are sized slightly smaller than the content. While debugging I determined it's because Graphics.MeasureString returns a different value in this context. I'm not sure why. My first thought was the method returns a different value in System.Drawing than System.Drawing.Common, but that doesn't explain why the sizing works fine from the unit test project which is also net461. I think System.Drawing.Common just delegates to GDI+ like System.Drawing does anyway.

I can't spend much more time looking into it, so thoughts and additional testing are welcome. Otherwise, I think it works well enough to merge considering the current version doesn't auto-size at all.

@yang-xiaodong yang-xiaodong self-requested a review October 11, 2018 14:36
@yang-xiaodong
Copy link
Member

Hello, thanks for your PR, AutoSizeColumn is a bug in the migration process. It is not an easy task to completely solve this problem. Anyway, thank you very much for your work. :)

@yang-xiaodong yang-xiaodong merged commit 947220d into dotnetcore:master Oct 11, 2018
@yang-xiaodong
Copy link
Member

I'll release a new version tomorrow

@gtbuchanan
Copy link
Contributor Author

My first thought was the method returns a different value in System.Drawing than System.Drawing.Common

I discovered that this is true. It showed up in my project because NPOI was first referenced from a netstandard2.0 library and that library referenced by net461 (NPOI -> netstandard -> net461). All that to say, my fixes work nearly perfect for NPOI net461 but are slightly off in NPOI netstandard2.0. I'll see if I'm able to submit another fix for netstandard at a later time.

@gtbuchanan gtbuchanan deleted the autosizecolumn-fix branch October 11, 2018 19:39
yang-xiaodong added a commit that referenced this pull request Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants