'Parsing excel sheet - cell by cell

I would like to see your help on how to parse an excel file in mvc c# but, accessing its cell address like:

var a = Excel_cell{A1:B1} model.a = a

I've looked to various plugin like excelfilereader, epplus and also javascript libraries like sheetjs and alike but, they do the same where they parse the whole file with the layout of a table...

My excel file is quite complicated because it has no headers and its data is on the right side. EG: sample from excel file

I apologize if I put an image here...

My requirement is read an excel template, and save its data to the database.. I dont need to send the file to server because it will not be beneficial in the long run

Im hoping you could help me... An idea how to accomplish this would be really help.



Solution 1:[1]

You can try by using Spire.XLS, It's a good library that helps you read and write (this one only with a license) excel files and some other formats, it's easy to use and intuitive, for example this would be the code to get an excel file and read some cells:

//Create a variable to access the excel file
Workbook yourFile = new Workbook();
Stream stream = new MemoryStream(FilePath);
//Load the excel file into the variable
workbook.LoadFromStream(stream);

//Select the worksheet you want to take values from
var firstSheet = workbook.Worksheets.Where(x => x.Name == "Name of the sheet").First() as Worksheet;

string value = firstsheet.Range[A1].Text;

So with this code you have populated a variable with the excel file, a variable with a specific sheet (for example the first one), and then you save the text value of a specific cell of your choice in another variable, let me know if I got it right

EDIT: This is their site and this is the nuget gallery

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sMuLe