JanKallman / EPPlus

Create advanced Excel spreadsheets using .NET
3.76k stars 1.18k forks source link

EPPlus Library With Column Auto Width #407

Open PriyankGadhiya opened 5 years ago

PriyankGadhiya commented 5 years ago

I use this EPPlus library and use code like this in it, but code does not work

for (int i = 1; i < ws.Cells.Count() + 3; i++) { ws.Column(i).AutoFit(); }

ErikNoren commented 5 years ago

You're using the count of ws.Cells (plus 3 more) but calling AutoFit on ws.Columns which seems strange.

There is AutoFitColumns on the Range which I use and works for me. If you want to autofit all your columns you could try something like:

worksheet.Cells[1, 1, 1, worksheet.Cells.End.Column].AutoFitColumns();
PriyankGadhiya commented 5 years ago

sir this syntax not working properly https://about.me/priyankgadhiya?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb Priyank Gadhiya about.me/priyankgadhiya https://about.me/priyankgadhiya?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb

On Tue, 26 Feb 2019 at 21:32, Erik Noren notifications@github.com wrote:

You're using the count of ws.Cells (plus 3 more) but calling AutoFit on ws.Columns which seems strange.

There is AutoFitColumns on the Range which I use and works for me. If you want to autofit all your columns you could try something like:

worksheet.Cells[1, 1, 1, worksheet.Cells.End.Column].AutoFitColumns();

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JanKallman/EPPlus/issues/407#issuecomment-467497762, or mute the thread https://github.com/notifications/unsubscribe-auth/AqR2GML8V1K8B6Q3hFt7Fh7S0junqXCOks5vRVqvgaJpZM4a-3Vf .