Reading from Excel File using ClosedXML

Nate Pet

My Excel file is not in tabular data. I am trying to read from an excel file. I have sections within my excel file that are tabular.

I need to loop through rows 3 to 20 which are tabular and read the data.

Here is party of my code:

     string fileName = "C:\\Folder1\\Prev.xlsx";
     var workbook = new XLWorkbook(fileName);
     var ws1 = workbook.Worksheet(1); 

How do I loop through rows 3 to 20 and read columns 3,4, 6, 7, 8? Also if a row is empty, how do I determine that so I can skip over it without reading that each column has a value for a given row.

Raidri supports Monica

To access a row:

var row = ws1.Row(3);

To check if the row is empty:

bool empty = row.IsEmpty();

To access a cell (column) in a row:

var cell = row.Cell(3);

To get the value from a cell:

object value = cell.Value;
// or
string value = cell.GetValue<string>();

For more information see the documentation.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ClosedXML read from excel file

From Dev

Downloading excel file from web api using closedxml

From Dev

Reading columns from excel file using linq

From Dev

Append to excel file with ClosedXML

From Dev

Reading from an Excel file

From Dev

How to append a new row to an Excel file using C# and ClosedXML?

From Dev

ClosedXML: Export To Excel not downloading the File MVC 4

From Dev

How to count number of columns Excel file in ClosedXML?

From Dev

Find a Row in Excel file based on a column value and Update the row value using ClosedXML

From Java

Reading an Excel file in python using pandas

From Dev

Reading Excel file using node.js

From Dev

Reading excel file using OLEDB Data Provider

From Dev

Reading Excel file using SheetJs - Javascript

From Dev

Reading data from Excel file in r

From Dev

open xml reading from excel file

From Dev

reading datenum instead of datestr from excel file

From Dev

open xml reading from excel file

From Dev

Reading or Writing Excel (xlsx) file from java

From Dev

reading datenum instead of datestr from excel file

From Dev

reading a file from text file using numpy

From Dev

Reading a cell from Excel using Apache POI

From Dev

Why format changes while reading data from excel file using poi api java?

From Dev

Reading Excel csv file with extra dot in file name using OLEDB

From Dev

Java reading from file and sending using DataOutputStream

From Dev

Reading a column from CSV file using JAVA

From Dev

Reading from file using read() function

From Dev

Reading data from file using Python cPickle

From Java

Reading a line from a file using perl

From Dev

Reading data from an XML File Using R

Related Related

HotTag

Archive