We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I find out the number of columns in a worksheet?

Thread ID:





53867 Dec 21,2006 03:21 PM UTC Dec 22,2006 10:34 AM UTC WinForms 1
Tags: XlsIO
Andrzej Krzywda
Asked On December 21, 2006 03:21 PM UTC

Hello all,

I thought that iterating over columns is appropriate way to do this, however it throws a ArgumentOutOfRangeException when I try to access Columns property in a worksheet that is empty.

static void Main()
ExcelEngine engine = new ExcelEngine();
IWorkbook workbook = engine.Excel.Workbooks.Open("c:\\empty.xls");
IWorksheet worksheet = workbook.Worksheets[0];




Melba Winshia [Syncfusion]
Replied On December 22, 2006 10:34 AM UTC

Hi Andrzej,

Use the following code snippets to find out the number of columns in a worksheet.


//Reading number of columns.
Console.WriteLine("No. of columns:"+sheet.Columns.Length.ToString());

Here is the sample for your reference:


Plese take look at the sample above and let me know if you have any other questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon