C#中怎么获取Excel数据的行数?求详细代码
2013-11-12 16:40:26雷***
C#中怎么获取Excel数据的行数?求详细代码。。。C#中怎么获取Excel数据的行数?求详细代码。。。: DataTable ExcelTable;
DataSet ds = new?
最佳回答
Jet。OLEDB。4。0;Data Source=EXCEL文件路径;" + "Extended Properties=Excel 8。0;"); objConn。Open(); DataTable schemaTable = objConn。
GetOleDbSchemaTable(System。Data。OleDb。OleDbSchemaGuid。Tables, null); string tableName = schemaTable。Rows[0][2]。ToString()。
Trim();//获取 Excel 的表名,默认值是sheet1 string strSql = "select * from [" + tableName + "]"; OleDbCommand objCmd = new OleDbCommand(strSql, objConn); OleDbDataAdapter myData = new OleDbDataAdapter(strSql, objConn); myData。
Fill(ds, tableName);//填充数据 dgBom。DataSource =ds; dgBom。DataBind(); objConn。Close(); ExcelTable = ds。
Tables[tableName]; int iColums = ExcelTable。Columns。Count;//列数 int iRows = ExcelTable。Rows。Count;//行数 。
2013-11-12 19:51:28
很赞哦! (111)
相关文章
- 魔兽世界的猎人的宠物的训练点数怎么获得?
- 三国志11宝物都有什么怎么获得比如玉
- 激战2特性点怎么获得,我的任务技能栏里
- 怎么得到共测帐号?大家帮帮我。:)我
- 改狗的零件如何得到?改狗的零件如何得到
- 梦幻西游,怎么看自己获得过的所有经验有多
- 改造黄蜂图怎么得到要买的话一个多少钱
- 香港股市一共有多少支股票?怎么样得到它们
- 里约热内卢IpanemaPalace
- 里约热内卢RioApartments
- 谁住过里约热内卢StudioVist
- 里约热内卢PaulaFreitas
- 谁住过里约热内卢Condominio
- 里约热内卢ApartamentoAn
- 里约热内卢SunnyStudio好吗
- 如何获取共享受资料积分
- QQ宠物怎么获得QQ宠物怎么获得
- 大话3怎么看共获得的物品
- c#中dataset里的数据可以直接导到
- 如何在excel中提取每个周期中的峰值
- 数据集“DataSet1”字段名称必须是