Using Visual Studio 2017, I installed reference packages through Nuget
- ExcelDataReader
- EcxelDataReader.DataSet version 3.4.0
I'm following a tutorial on how to open XLS file and this one giving error in the following line, I would like to know how to solve this error.
The line that is giving error is this in the code below:
reader.IsFirstRowAsColunmNames = true;
It says it does not contain this definition in IExcelDataReader
I'm using the following using below
- using ExcelDataReader;
- using System;
- using System.Data;
- using System.IO;
-
using System.Windows.Forms;
private void btnOpen_Click(object sender, EventArgs e) { DataSet result; using (OpenFileDialog ofd = new OpenFileDialog() {Filter="Excel Workbook *.xls", ValidateNames = true }) { if(ofd.ShowDialog() == DialogResult.OK) { FileStream fs = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); IExcelDataReader reader = ExcelReaderFactory.CreateBinaryReader(fs); reader.IsFirstRowAsColunmNames = true; result = reader.AsDataSet(); cbbPlanilha.Items.Clear(); foreach (DataTable dt in result.Tables) { cbbPlanilha.Items.Add(dt.TableName); } reader.Close(); } } }