I have a Excel file (.xlsx) with a sheet, which looks like this:
Name | Age | Country |
Nik 17 Switzerland
Thomas 28 Kuba
Waslim 12 Russia
I want to convert this excel sheet into JSON Format.
The result should look like this:
[
{
"Name":"Nik",
"Age":17,
"Country":"Switzerland"
},
{
"Name":"Thomas",
"Age":28,
"Country":"Kuba"
},
{
"Name":"Waslim",
"Age":12,
"Country":"Russia"
}
]
I would like to use the LightweightExcelReader framework. I know that there is a similar question already asked, but the answer uses OLEDB which shouldn't be best practice anymore. I would like to solve this transformation with a easier and faster framework.
IMPORTANT: The number of rows and columns is dynamic and can vary, but the format of the excel sheet stays from sheet to sheet the same.
Here is my attempt. As you can see i didn't manage alot and it's pretty basic. I managed to get the first row for the key in the JSON:
var excelReader = new ExcelReader(@"path\to\file\test.xlsx");
var sheetReader = excelReader[0];
IEnumerable<object> keys = sheetReader.Row(1);
How can I convert a Excel Sheet to JSON Format using the LightweightExcelReader Framework?