打印本文 打印本文 关闭窗口 关闭窗口
Asp.net操作Excel(导入导出)-
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1023  更新时间:2009/6/9 2:35:15  文章录入:mintao  责任编辑:mintao
///
/// 读取Excel文档
///
/// 文件名称
/// 返回一个数据集
public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcel="select * from [sheet1$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds,"table1");
return ds;
}
打印本文 打印本文 关闭窗口 关闭窗口