Lexerow 0.5.0

dotnet add package Lexerow --version 0.5.0
                    
NuGet\Install-Package Lexerow -Version 0.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lexerow" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lexerow" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Lexerow" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lexerow --version 0.5.0
                    
#r "nuget: Lexerow, 0.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lexerow@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lexerow&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Lexerow&version=0.5.0
                    
Install as a Cake Tool

What is Lexerow ?

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

For example you can 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 row or in another cell of the row.

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 in the first sheet: 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. It would better to have a value in each cell.

Comment: In Excel language, we say blank rather than empty.

+------+-------+
|  Id  | Value |
+------+-------+
|   1  |   12  |
|   2  |       |  <= is empty!
|   3  |  234  |
|   4  |       |  <= is empty!
|   5  |  631  |
+------+-------+

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

+------+-------+
|  Id  | Value |
+------+-------+
|   1  |   12  |
|   2  |    0  |  <= set to 0
|   3  |  234  |
|   4  |    0  |  <= set to 0
|   5  |  631  |
+------+-------+

The solution

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

-2/ Create a dotnet program to execute your script.

-3/ Feel free to modify the script as needed and execute it again.

The Script to fix values

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

Let's consider the excel file to fix blank values is "file.xlsx". The first row is the header. Data starts at the second row which is the default case.

Create a basic script as a text file and save it let's say with this name: "script.lxrw"

The file name extension is free.

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

The script will scan each datarow present in the sheet starting by defaut from the row #2. Each time the cell value in column B is blank, the value 0 will be set in place. The execution will stop automatically after the last row was processed.

This a very basic script with few instructions to manage this standard case, but of course it's possible to create more complex scripts to manage all your specific cases.

A C# program to execute the script

Now let's open your Visual Studio or VSCode. First import the nuget Lexerow package in your solution or project.

Create a program in C# and use it in this way:

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

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

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

Project Github

The source code is hosted on github here:

https://github.com/Pierlam/Lexerow

To go further - Script tuning

Now let's manage a specific case of your datatable.

If the header use 2 rows or more, it's possible to set a different first data row to process. For example, start at the row #3 in place of default row #2. You may use the instruction FirstRow.

# process datarow of the Excel, one by one
OnExcel "file.xlsx"
	FirstRow 3
    ForEachRow
	  If B.Cell=blank Then B.Cell=0
    Next
End OnExcel	

There are several kind of checks available in If condition:

If A.Cell=12
If A.Cell>8.55
If A.Cell<>"Hello"
If A.Cell=blank
If A.Cell=null
If A.Cell <= Date(2019,11,14) 
If A.Cell >10 And B.Cell< 20
If (A.Cell >10 And B.Cell< 20) Or C.Cell=12

In Then instruction, you can set a value to a cell or clear it.

To clear the cell value, you can put blank in it. The formating of the cell will remain: background/foreground color and border.

To remove completly a cell (value and formatting) , you have to set it to null.

For If and Then instruction, type of value can be: int, double, string and now Date.

DateTime and time will be managed later.

Then A.Cell=13
Then A.Cell=25.89
Then A.Cell="Hello"
Then A.Cell=blank    # cell formatting will stay
Then A.Cell=null     # cell formatting will be cleared
Then A.Cell=Date(2019,11,14) 

From a technical point of view, you can manage easily errors occured during compilation or during the execution of scripts.

OnExcel "file.xlsx"
	FirstRow 3
    ForEachRow
	  If A.Cell="Y" Then 
		A.Cell="N"
		B.Cell=25.89
		C.Cell=blank
	  End If
    Next
End OnExcel	

You can also manage easily errors occuring during compilation or during the execution of scripts.


// load and execute the script   
var result= core.LoadExecScript("MyScript", "MyScript.lxrw");   
if(!result.Res)
{
	// errors occured -> see result.ListError
	// On an error, see ErrorCode to know the type of error that occured
}

Project Wiki

You can find more information on how to create more powerful scripts:

https://github.com/Pierlam/Lexerow/wiki

Dependency

To access Excel content file, Lexerow uses now the OpenExcelSdk library available on Nuget here:

https://www.nuget.org/packages/OpenExcelSdk

Source code is hosted on github here:

https://github.com/Pierlam/OpenExcelSdk

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 103 1/10/2026
0.4.0 186 11/23/2025
0.3.0 300 11/16/2025
0.2.0 211 6/22/2025
0.1.1 276 4/13/2025
0.1.0 259 4/8/2025

## 0.5.0 Release (2026-31-01)

-Access to Excel: NPOI Library replaced by OpenExcelSdk.

-New: Date function in place. Date(year, month, day)

an be used in If or then part, in a variable and more.

By default display with the default format: dd/mm/yyyy

-New: You can change the default display format for date:

e.g. $DateFormat="yyyy-mm-dd"

-Now string comparison are by default case insensitive.

But it's possible to change the default behavior by setting the system var to true.

$StrCompareCaseSensitive=true

-And and Or boolean operator can be used in If conditiion.

e.g.  If A.Cell>10 And A.Cell<20 Then..

-Variable can be used. e.g.

a=12

..

If A.Cell>a Then

-Creation of the class Diagnotics available in the core to manage easily logs/traces.

-166 unit tests, all are green.

-Bugs fixed