Asp.net操作Excel(导入导出)-
Admin |
2007-10-10 22:29:36 | ReadNums |
5705 | 标签
asp.net |
打印本页
///
/// 读取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;
}
问题未解决:
网友评论

- (访客)
- 内容实用原创,讲得很好。
- 20xx年x月x日

- (站长)
- 有问题请在线咨询。
- 20xx年x月x日