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.
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:

Created:

Updated:

Platform:

Replies:

53867 Dec 21,2006 10:21 AM Dec 22,2006 05:34 AM Windows Forms 1
loading
Tags: XlsIO
Andrzej Krzywda
Asked On December 21, 2006 10:21 AM

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];
Console.WriteLine(worksheet.Columns);

}

Thanks,
Andrzej

empty0.zip

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

Hi Andrzej,

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

[C#]

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

Here is the sample for your reference:

NumberOfColumns.zip


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

Thanks,
Melba

CONFIRMATION

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.

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

;