My application needs to read data from an excel file and stocks it in MongoDB database. I am using .Net and c# for development.I am using Excel 2007 , MongoDB 3.2 and visual studio 2015 version. Any idea to access excel file, i need your help please.
This is my code
public void Open_readXLS()
{
Excel.Workbook workbook;
Excel.Worksheet worksheet;
Optioncontext ctx = new Optioncontext();
string filePath = @"C:\Users\user PC\Desktop\ finale\Euro_Dollar_Call_Options.xlsx";
workbook = new Excel.Workbook(filePath);
worksheet = workbook.Sheets.GetByName("Feuil1");
for (ushort i = 0; i <= worksheet.Rows.LastRow; i++)
{
option.type_option= worksheet.Rows[i].Cells[0].Value.ToString(),
option.type_currency= worksheet.Rows[i].Cells[1].Value.ToString();
}
ctx.Option.InsertOne(option);
}