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

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

You might want to mention that you need to include the namespace by typing "using Excel;"
It took me a minute to figure this out because you can't see all of the using statements that you have. Otherwise, great video thanks for the help.

Jonaldinho
Автор

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

mikemunoz
Автор

The video is practical and perfect.Thanks ...

Автор

thank you so much, this works like a charm!!

mohdaliff
Автор

Another example of awesom work, you´re the boss, i´ill repeat forever, :D

DARKAR_
Автор

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 =
else
reader =

var conf = new ExcelDataSetConfiguration
{
ConfigureDataTable = _ => new ExcelDataTableConfiguration
{
UseHeaderRow = true
}
};

result = reader.AsDataSet(conf);

cbSheet.Items.Clear();

foreach (DataTable dt in result.Tables)


reader.Close();
}
}

estaverde
Автор

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

marylandmacapilit
Автор

You are very active last days, nice :)

harisavdic
Автор

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?

RafMoh
Автор

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

mamdouhaljunied
Автор

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 :)

xghimhg
Автор

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.

wonjaejung
Автор

I can't write this code IExcelDataReader

Trungkienelectronic
Автор

How to delete columns present in excel using c#

vikasgowda
Автор

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?

emmanuelbollie
Автор

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

sergeantsucker
Автор

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

please help

gamingghost
Автор

Hi. I have a problem in this code line
reader =
'No se puede cargar el archivo o ensamblado 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, ni una de sus dependencias. El sistema no puede encontrar el archivo especificado.'
What can i do to solve this?
Thanks.

moruscalipe
Автор

hello. I'm getting error NullReferenceException: Object reference not set to an instance of an object.
At foreach<..> result.Tables. What should I do?

booney
Автор

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

TheInternetdirect
visit shbcf.ru