日期:2014-05-20  浏览次数:20367 次

|M| 如何将sql查询语句查询出来的表存为Excel 谢谢
如我要把
select   top   100   *   from   product   order   by   id   desc
这个语句所查询出来的数据存储为Excel格式
谢谢

PS:给个相符的URL也可以

谢谢

------解决方案--------------------
可以直接在PLSQL Developer查出结果后选中数据右键菜单有直接导入Excel的选项
------解决方案--------------------
http://dev.10026.com/sql/bclass/2005815701_4146899.shtml
------解决方案--------------------
http://hi.baidu.com/wuhy/blog/item/b067bca11246fb8b471064db.html
------解决方案--------------------
System.Web.HttpContext obj = System.Web.HttpContext.Current;
obj.Response.Clear();
obj.Response.Buffer = true;
//obj.Response.Charset= "GB2312 ";
obj.Response.AddHeader( "Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(strFileName, Encoding.UTF8) + ".xls ");
obj.Response.ContentEncoding = System.Text.Encoding.UTF8;//设置输出流为简体中文
obj.Response.ContentType = "application/ms-excel ";//设置输出文件类型为excel文件。
obj.Response.ContentType = "application/vnd.ms-excel ";
//System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo( "ZH-CN ",true);
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
dg.RenderControl(htw);

obj.Response.Write(sw.ToString());
obj.Response.End();
------解决方案--------------------
学习了~~
------解决方案--------------------
1,使用exec master.dbo.xp_cmdshell 'bcp "select top 100 * from product order by id desc " queryout "d:\xx.csv " -w -S. -Usa -Psa '
2,使用DFVV8((忽然发现,俩裤衩了,向三只裤衩前进!)) 的方法,
3,使用winform的office类库生成
------解决方案--------------------
^_^
------解决方案--------------------
在程序里生成需要用office类库
------解决方案--------------------
:)
------解决方案--------------------
exec master.dbo.xp_cmdshell 'bcp "select top 100 * from product order by id desc " queryout "d:\xx.csv " -w -S. -Usa -Psa '
------解决方案--------------------
http://post.baidu.com/f?kz=92210440
------解决方案--------------------
[M]帖子估计都与楼主有关

不好意思
全不会,捡分!

------解决方案--------------------
DFVV8的方法可行