filmov
tv
How to read data from an excel file with C# using Excel Data Reader
Показать описание
How to read data from an excel file with C# using Excel Data Reader
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using ExcelDataReader;
using System.Data;
namespace readExcelReader
{
internal class Program
{
static void Main(string[] args)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var streamval = File.Open(filepath, FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(streamval))
{
var configuration = new ExcelDataSetConfiguration
{
ConfigureDataTable = _ = new ExcelDataTableConfiguration
{
UseHeaderRow = false
}
};
var dataSet = reader.AsDataSet(configuration);
if (dataSet.Tables.Count 0)
{
var dataTable = dataSet.Tables[0];
Console.WriteLine("Rows : " + dataTable.Rows.Count);
Console.WriteLine("Columns : " + dataTable.Columns.Count);
}
else
{
Console.WriteLine("Sheet doesn't exist");
}
}
}
}
}
}
Chapters:
0:00 - Introduction to the video
1:11 - Procedure to read data from excel by excel data reader
8:41 - End Tags and Subscription to the channel
My second Channel:
Follow Insta:
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#excel
#csharp
#csharptutorial
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using ExcelDataReader;
using System.Data;
namespace readExcelReader
{
internal class Program
{
static void Main(string[] args)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var streamval = File.Open(filepath, FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(streamval))
{
var configuration = new ExcelDataSetConfiguration
{
ConfigureDataTable = _ = new ExcelDataTableConfiguration
{
UseHeaderRow = false
}
};
var dataSet = reader.AsDataSet(configuration);
if (dataSet.Tables.Count 0)
{
var dataTable = dataSet.Tables[0];
Console.WriteLine("Rows : " + dataTable.Rows.Count);
Console.WriteLine("Columns : " + dataTable.Columns.Count);
}
else
{
Console.WriteLine("Sheet doesn't exist");
}
}
}
}
}
}
Chapters:
0:00 - Introduction to the video
1:11 - Procedure to read data from excel by excel data reader
8:41 - End Tags and Subscription to the channel
My second Channel:
Follow Insta:
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#excel
#csharp
#csharptutorial
Комментарии