主頁 > 知識庫 > .NET中讀取Excel文件的數(shù)據(jù)及excelReader應(yīng)用

.NET中讀取Excel文件的數(shù)據(jù)及excelReader應(yīng)用

熱門標簽:南陽外呼系統(tǒng)定制化 玉林市機器人外呼系統(tǒng)哪家好 合肥電銷外呼系統(tǒng)哪家公司做的好 同安公安400電話怎么申請流程 申請400電話手續(xù) 電話機器人軟件銷售工作 蘋果手機凱立德地圖標注 預測式外呼系統(tǒng)使用說明 百度ai地圖標注
項目介紹
輕量,快速的C#編寫的庫讀取Microsoft Excel文件('97-2007)。
跨平臺:
- Windows with .Net Framework 2
- Windows Mobile with Compact Framework
- Linux, OS X, BSD with Mono 2+
如何使用
C# 代碼:
復制代碼 代碼如下:

FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
//...
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
//...
//3. DataSet - The result of each spreadsheet will be created in the result.Tables
DataSet result = excelReader.AsDataSet();
//...
//4. DataSet - Create column names from first row
excelReader.IsFirstRowAsColumnNames = true;
DataSet result = excelReader.AsDataSet();
//5. Data Reader methods
while (excelReader.Read())
{
//excelReader.GetInt32(0);
}
//6. Free resources (IExcelDataReader is IDisposable)
excelReader.Close();

VB.NET 代碼:
復制代碼 代碼如下:

Dim stream As FileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)
'1. Reading from a binary Excel file ('97-2003 format; *.xls)
Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateBinaryReader(stream)
'...
'2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateOpenXmlReader(stream)
'...
'3. DataSet - The result of each spreadsheet will be created in the result.Tables
Dim result As DataSet = excelReader.AsDataSet()
'...
'4. DataSet - Create column names from first row
excelReader.IsFirstRowAsColumnNames = True
Dim result As DataSet = excelReader.AsDataSet()
'5. Data Reader methods
While excelReader.Read()
'excelReader.GetInt32(0);
End While
'6. Free resources (IExcelDataReader is IDisposable)
excelReader.Close()
您可能感興趣的文章:
  • ASP.NET(C#)讀取Excel的文件內(nèi)容
  • .net客戶端導出Excel實現(xiàn)代碼及注意事項
  • .Net中導出數(shù)據(jù)到Excel(asp.net和winform程序中)
  • asp.net生成Excel并導出下載五種實現(xiàn)方法
  • C#數(shù)據(jù)導入/導出Excel文件及winForm導出Execl總結(jié)
  • ASP.NET下將Excel表格中的數(shù)據(jù)規(guī)則的導入數(shù)據(jù)庫思路分析及實現(xiàn)
  • ASP.NET導出Excel打開時提示:與文件擴展名指定文件不一致解決方法
  • asp.net Grid 導出Excel實現(xiàn)程序代碼
  • C#實現(xiàn)EXCEL數(shù)據(jù)到TXT文檔的轉(zhuǎn)換

標簽:南京 海南 揚州 南昌 南京 淄博 嘉興 臺州

巨人網(wǎng)絡(luò)通訊聲明:本文標題《.NET中讀取Excel文件的數(shù)據(jù)及excelReader應(yīng)用》,本文關(guān)鍵詞  .NET,中,讀取,Excel,文件,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《.NET中讀取Excel文件的數(shù)據(jù)及excelReader應(yīng)用》相關(guān)的同類信息!
  • 本頁收集關(guān)于.NET中讀取Excel文件的數(shù)據(jù)及excelReader應(yīng)用的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章