Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
How to find last used column in excel file?
posted

Hello,

I need to iterate worksheet columns collection in code but i need to know the last used column in worksheet.

Could you advise me how to find last used column?

my code example:

using Infragistics.Documents.Excel;
...
for (int i = 0; i < lastUsedColumn; i++)
{
...
}

before I used Worksheets[0].Columns collection but it skipped some columns in worksheet.


foreach(var column in workbook.Worksheets[0].Columns) 
{
...
}


Thank you

Libor