Skip to content
Pierlam-dev edited this page Nov 16, 2025 · 7 revisions

What is Lexerow ?

Lexerow is a backend dotnet library to process easily datarows and cells in Excel files (xlsx).

You can for example detect empty cell in a column and set a specific value. You can compare a cell value to a specific value and then put a new value in the same cell row or in another cell.

Lexerow is developed in C# and can be used in any dotnet application.

Lexerow is an open source library.

A quick example

Problem: empty cells

You have an Excel file containing a datatable: the first line is the header, and others are datarows of the table. In column B, some cells are empty, and it's a problem to do calculation. It would better to have a value in each cell.

Some cells are empty

So to put the value 0 in each empty cell in column B, Lexerow will help you to do that easily with some lines of code.

Cells have now values

The solution, in 2 stages

-1/ Create a script to fix cell values in the Excel datatable.

-2/ Execute the script in a C# program.

The Script to fix values

To process datarow of the excel file as explained, Lexerow provide a powerful instruction which is: OnExcel ForEachRow If/Then.

Let's consider the excel file to fix blank values is "MyFile.xlsx"

Create a basic script and save it "MyScript.lxrw"

# process datarow of the Excel, one by one
OnExcel "MyFile.xlsx"
    ForEachRow
	  If B.Cell=null Then B.Cell=0
    Next
End OnExcel	

This a very basic script, but of course it's possible to create more complex script to manage different cases.

A C# program to execute the script

Create a program in C# and use the Lexerow library in this way:

// create the core engine
LexerowCore core = new LexerowCore();

// load and execute the script   
core.LoadExecScript("MyScript", MyScript.lxrw);   

This is the minimum C# program you have to write.