请问如何才能把一个excel文件的内容导入到dataset中呢? 谢谢! http://dev.csdn.net/Develop/article/15/15544.shtm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Excel.Application excel= new Excel.Application(); int rowIndex=1; int colIndex=0; excel.Application.Workbooks.Add(true); DataTable table=GetData(); //将所得到的表的列名,赋值给单元格 foreach(DataColumn col in table.Columns) { colIndex++; excel.Cells[1,colIndex]=col.ColumnName; } //同样方法处理数据 foreach(DataRow row in table.Rows) { rowIndex++; colIndex=0; foreach(DataColumn col in table.Columns) { colIndex++; excel.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString(); } } //不可见,即后台处理 excel.Visible=true; 我是初学者,该怎样理解代码及格式 C# 自动生成代码 编译 执行 有什么好的作用吗? 该用哪种"样式"的三层架构??? 老是提示:[]内索引数错误,应为“2”(二维数组) 拖动过程中的滚动问题 怎样才能得到RadioButton的值 面向对象书籍?? C#高级编程的代码,为将代码改为form响应click事件,做了如下改动,为何不行? 寻个时间判断的思路: 我在QQ上开了一个c#讨论组,欢迎大家加入! 奇怪的现象,C#自动把bin\*.dll的文件删除啦。 请有实际开发经验的谈谈.dll文件的使用
int rowIndex=1;
int colIndex=0; excel.Application.Workbooks.Add(true);
DataTable table=GetData();
//将所得到的表的列名,赋值给单元格
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[1,colIndex]=col.ColumnName;
} //同样方法处理数据
foreach(DataRow row in table.Rows)
{
rowIndex++;
colIndex=0;
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString();
}
}
//不可见,即后台处理
excel.Visible=true;