Skip to content

Commit b8e8666

Browse files
authored
Merge pull request #2332 from syncfusion-content/997915-ReadColumn
Documentation(997915): Add FAQ for how to read all values from a specific column name in an Excel worksheet using XlsIO
2 parents 4e2f568 + 403ef52 commit b8e8666

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

Document-Processing-toc.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6489,6 +6489,9 @@
64896489
<li>
64906490
<a href="/document-processing/excel/excel-library/net/faqs/why-formulas-referencing-the-deleted-column-show-ref-errors">Why do formulas referencing a deleted column show #REF! errors?</a>
64916491
</li>
6492+
<li>
6493+
<a href="/document-processing/excel/excel-library/net/faqs/how-to-read-all-values-of-a-column">How to read all values from a specific column in an Excel worksheet using XlsIO?</a>
6494+
</li>
64926495
</ul>
64936496
</li>
64946497
</ul>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: How to read all values of a column | Syncfusion
3+
description: This page explains how to read all values of a column in an Excel worksheet using Syncfusion .NET Excel library (XlsIO).
4+
platform: document-processing
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# How to read all values from a column in an Excel worksheet?
10+
11+
The following code example illustrates how to read all values from a specific column in an Excel worksheet using XlsIO in C# (cross-platform and Windows-specific) and VB.NET.
12+
13+
{% tabs %}
14+
{% highlight c# tabtitle="C# [Cross-platform]" %}
15+
using (ExcelEngine excelEngine = new ExcelEngine())
16+
{
17+
IApplication application = excelEngine.Excel;
18+
application.DefaultVersion = ExcelVersion.Xlsx;
19+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
20+
IWorksheet worksheet = workbook.Worksheets[0];
21+
22+
// Select the column
23+
string columnName = "E";
24+
foreach (IRange row in sheet.Rows)
25+
{
26+
// Read all the value of a column
27+
var val = sheet[columnName + row.Row].Value;
28+
}
29+
}
30+
{% endhighlight %}
31+
32+
{% highlight c# tabtitle="C# [Windows-specific]" %}
33+
using (ExcelEngine excelEngine = new ExcelEngine())
34+
{
35+
IApplication application = excelEngine.Excel;
36+
application.DefaultVersion = ExcelVersion.Xlsx;
37+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
38+
IWorksheet worksheet = workbook.Worksheets[0];
39+
40+
// Select the column
41+
string columnName = "E";
42+
foreach (IRange row in sheet.Rows)
43+
{
44+
// Read all the value of a column
45+
var val = sheet[columnName + row.Row].Value;
46+
}
47+
}
48+
{% endhighlight %}
49+
50+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
51+
Using excelEngine As ExcelEngine = New ExcelEngine()
52+
Dim application As IApplication = excelEngine.Excel
53+
application.DefaultVersion = ExcelVersion.Xlsx
54+
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")
55+
Dim worksheet As IWorksheet = workbook.Worksheets(0)
56+
57+
' Select the column
58+
Dim columnName As String = "E"
59+
For Each row As IRange In worksheet.Rows
60+
Dim cellAddress As String = columnName & row.Row.ToString()
61+
' Read all the value of a column
62+
Dim val = worksheet(cellAddress).Value
63+
Next
64+
End Using
65+
{% endhighlight %}
66+
{% endtabs %}

0 commit comments

Comments
 (0)