C# Tutorial – How to read an excel (.xls/.xlsx) file | FoxLearn

How to read an excel (*.xls/.xlsx) file in C#. The C# Basics beginner course is a free C# Tutorial Series that helps beginning programmers learn the basics of the C# Programming Language. This is the best way to Learn C# for beginners

c# – Optimal way to Read an Excel file (.xls/.xlsx)
How to read the xls and xlsx files using c#
.net – Reading Excel files from C#
Read Excel XLS XLSX files in C#
Read and display data from an excel file (.xls and .xlsx)
Excel Data Reader – Read Excel files in .NET
Read Excel File in C# (Example)
C# – How To Get Data From Excel File In C# [with source code]
How to import excel file to datagridview in c#
How to Open Excel File in C#
C# Import From Excel Using OleDb Tutorial

Nguồn: https://kuherbal.com/

Xem thêm bài viết khác: https://kuherbal.com/category/cong-nghe


  1. Memo.
    c# exceldatareader example

  2. iv a two pbs
    1. that when i click or select the sheet again so it reads the excel again and that wht idn want have
    2. when the sheet is empty so ive to show a messagebx that the Sheet empty si how i can check if the Sheet empty or not thank you so much 🙂

  3. also the same:

    "IExcelDataReader" enthält keine Definition für "AsDataSet"
    what is to do?

  4. Hi. I have a problem in this code line
    reader = ExcelReaderFactory.CreateOpenXmlReader(fs);
    System.IO.FileNotFoundException: 'No se puede cargar el archivo o ensamblado 'ICSharpCode.SharpZipLib, Version=, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' ni una de sus dependencias. El sistema no puede encontrar el archivo especificado.'

    What can i do to solve this?

  5. reader.IsFirstRowAsColumnName = true; doesnt show up, Cant add "using Excel;" i added "using ExcelDataReader;" help

  6. reader.IsFirstRowAsColumnNames <——-No this property

  7. hello i am getting error like this can anyone have solution?
    System.IO.FileNotFoundException: 'Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.'

  8. I get a cboSheet doesn't exist. Any help with this one?

  9. Here is the working code for newer version. I found it on source's github and combined it with this video's code
    NOTE: need to nuget both ExcelDataReader and ExcelDataReader.DataSet

    using (OpenFileDialog open = new OpenFileDialog() { Filter = "Excel Workbook (*.xlsx)|*.xlsx|Excel 97-2003 Workbook (*.xls)|*.xls", ValidateNames = true })


    if (open.ShowDialog() == DialogResult.OK)


    using (FileStream fs = File.Open(open.FileName, FileMode.Open, FileAccess.Read))

    using (var reader = ExcelReaderFactory.CreateReader(fs))


    result = reader.AsDataSet();


    foreach (DataTable dt in result.Tables)





  10. For those which are interested to compile the above demo with the last ExcelDataReader 3.x, the corrections proposed here worked well for me:

    Or if you prefer, the following corrected code is working for 3.x versions. But you need to also install the ExcelDataReader.DataSet package from NuGet:
    using (OpenFileDialog ofd = new OpenFileDialog() {Filter = "Excel Workbook 97-2003|*.xls|Excel Workbook|*.xlsx", ValidateNames = true})
    if (ofd.ShowDialog() == DialogResult.OK)
    FileStream fs = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);

    IExcelDataReader reader;

    if (ofd.FilterIndex == 1)
    reader = ExcelReaderFactory.CreateBinaryReader(fs);
    reader = ExcelReaderFactory.CreateOpenXmlReader(fs);

    var conf = new ExcelDataSetConfiguration
    ConfigureDataTable = _ => new ExcelDataTableConfiguration
    UseHeaderRow = true

    result = reader.AsDataSet(conf);


    foreach (DataTable dt in result.Tables)


  11. hello. I'm getting error NullReferenceException: Object reference not set to an instance of an object.

    At foreach<..> result.Tables. What should I do?

  12. hey how to fix this ??
    ExcelDataReader.Exceptions.HeaderException HResult=0x80131500 Message=Invalid file signature. Source=ExcelDataReader

    please help

  13. Thank you Fox learn! But, I faced the some problem that is when I import the excel file, it doesn't import excel style. How to import the excel format/style in WInforms.

  14. I can not read xlsx files. I'm getting this error:

    Message=Invalid file signature.

    Any ideas how to solve it?

  15. Hello i getting this errorSystem.NullReferenceException: 'Object reference not set to an instance of an object.'

    result was null. can you pls help me with this?

  16. I tried this and working fine, but i have need to reuse the data read from excel to check with values are available in database.
    so plz send the code to reuse returning data viruvenkat27@gmail.com

  17. Please send me a code,



  18. Hello, I am currently working on a very important project. May I ask if any of the good programmers can help me with it? It's actually using Visual C# to read an Excel/Word file populate into the Outlook calendar and the professors view the calendar using their mobile device. Will appreciate if any of y'all are able to help/guide me. Thank you. My email is limseeyin@gmail.com

  19. the solution for IsFirstRowAsColumnNames is install the version 2.1 because the last version 3.0 is incompatible for this method :')

  20. isfirstrowascolumnNames is showing error as no extension method , pls help me , mail @ jsthivyasekar@gmail.com

  21. hi, i installed the ExcelData reader and the IExcelDataReader doesnt show up.

    please help.

    thanks a lot

  22. I Get a RED squiggly line under 'IExcelDataReader' & 'ExcelReaderFactory' any help…??? Thanks in Advance

  23. please send code to me thanks

  24. Please send to my email anas.kadaoui@pchalle.ma

  25. Please send to my email anas.kadaoui@pchalle.ma

  26. please send me ahmetdsp@gmail.com

  27. Thank you foxlearn for your great efforts to help people learn C#. As all the past sample worked perfectly with me, this one does not, it shows the red lilne under 'reader' with a tip says:" 'reader' is a variable but used as a type ". any suggestions please?

  28. I keep getting a squiggly line under '.IsFirstRowAsColumnNames'. For some reason, 'IsFirstRowAsColumnNames' doesn't even appear in the intellisense. Is there a reference i am not getting right?

  29. Please send to my email baderkhezami000@gmail.com

  30. first of all thank you very much for this great video.
    I am wondering how I can read date and time correctly because the date and time were read float, not as date and time

  31. Hi, Im getting an error "Form1.result is never assigned to, and will always have its default value null"

  32. How to load the excel file directly in the datagridview without using combo box?
    Please Help, Thanks

  33. why IExcelDataReader is not active????

  34. why IExcelDataReader is not acctive

Leave a Reply

Your email address will not be published. Required fields are marked *