.NET中读取Excel文件的数据及excelReader应用
程序员文章站
2024-03-05 12:46:30
项目介绍 轻量,快速的c#编写的库读取microsoft excel文件('97-2007)。 跨平台: - windows with .net framework 2 -...
项目介绍
轻量,快速的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()
轻量,快速的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()
上一篇: java练习题11
推荐阅读
-
.NET中读取Excel文件的数据及excelReader应用
-
ASP.NET下将Excel表格中的数据规则的导入数据库思路分析及实现
-
.NET中读取Excel文件的数据及excelReader应用
-
asp.net读取excel中的数据并绑定在gridview
-
asp.net读取excel中的数据并绑定在gridview
-
Python3实现将文件归档到zip文件及从zip文件中读取数据的方法
-
MATLAB怎么读取excel文件中的数据?
-
MATLAB怎么读取excel文件中的数据?
-
Python3实现将文件归档到zip文件及从zip文件中读取数据的方法
-
asp.net上传Excel文件并读取数据的实现方法