Definition Isfirstrowascolunmnames not existing in Iexceldatareader of Exceldatareader reference

Asked

Viewed 56 times

0

Using Visual Studio 2017, I installed the reference packages through Nuget

  • Exceldatareader
  • Ecxeldatareader.Dataset version 3.4.0

I am following a tutorial on how to open XLS file and is giving error on the following line, I would like to know how to resolve this error.

The line that is giving error is this in the code below:

Isfirstrowascolunmnames = true;

It says that 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();
            }
        }
    }
    
  • There is no such method, so of the problem, maybe it is something related to the version, or not even in the tutorial which is the version of ExcelDataReader???

  • Exceldatareader version is 3.4.0

  • You don’t have that method! It doesn’t exist

1 answer

-1

After installing the "Exceldatareader" package by Nuget just include the library:

using Excel;

From there the Exceldatareader library will no longer be required.

If you still have problems, try changing the version of Exceldatareader (version 2.1.2.3 worked for me)

I got this solution on the site below. Following the instructions there works: (https://foxlearn.com/article/how-to-read-excel-file-in-csharp-159.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.