如何将一个sql取出的数据导入excel(在Web中)? 参考http://expert.csdn.net/Expert/topicview.asp?id=1604105 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://support.microsoft.com/default.aspx?scid=kb;EN-US;306023 using System.Data;using System.Data.SqlClient;private System.Data.DataTable GetData(){SqlConnection conn= new SqlConnection(@"Server=PXGD2;Initial Catalog=pingxiang;Uid=sa;Pwd=cloud;");SqlDataAdapter adapter= new SqlDataAdapter("select * from table",conn);DataSet ds= new DataSet();try { adapter.Fill(ds,"Customer"); }catch(Exception ex) { MessageBox.Show(ex.ToString()); }return ds.Tables[0];} to zwztu():你给的这个例子是把DataGrid控件中的数据导入到excel,我要的是从查询出的一个数据集中导入到excel。不过还是非常感谢 C# 判断数据库表中字段中某一数据是否存在?? 网游加速软件 帮我理解一个asp.net中三层模式的一些问题。 非常菜鸟问题 c#中如何在随机事件执行随机时间长度的事件。 新手问题马上结帖!求DateGridView更新数据方法。 问个关于SESSION的问题。 请大家推荐一本用C#写的.net的入门书,有案例的更好。现在很多书的都是东拼西抄,质量太次的多,怕买错。 C#有关编译原理 是不是安装了WIN2K的SP3以后就不能装VS.NET了 Array in Structure when calling functions in dll writtern in c 获得Dll文件版本
using System.Data.SqlClient;private System.Data.DataTable GetData()
{
SqlConnection conn= new SqlConnection(@"Server=PXGD2;Initial Catalog=pingxiang;Uid=sa;Pwd=cloud;");
SqlDataAdapter adapter= new SqlDataAdapter("select * from table",conn);DataSet ds= new DataSet();
try
{
adapter.Fill(ds,"Customer");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
return ds.Tables[0];
}
你给的这个例子是把DataGrid控件中的数据导入到excel,我要的是从查询出的一个数据集中导入到excel。不过还是非常感谢