如何从数据库中提取数据到excell文件并生成图形 [英] how to extract data from database to an excell file and generate graph
本文介绍了如何从数据库中提取数据到excell文件并生成图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个从excel文件中显示图形的项目。 excel文件是从数据库生成的。输入文件是.csv格式。以.xls格式输出文件。如何使用PHP或.net或java,vb?
解决方案
这个螨帮助你.... br $>
public static void ExportXls(GridView gridName,string filename)
{
HttpContext.Current.Response.Clear() ;
HttpContext.Current.Response.AddHeader(content-disposition,attachment; filename =+ filename +。xls);
HttpContext.Current.Response.Charset =;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.ContentType =application / Excel;
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
gridName.RenderControl(htmlWrite);
HttpContext.Current.Response.Write(stringWrite.ToString());
HttpContext.Current.Response.End();
}
要导出到excel的页面中需要使用foll方法...
public override void VerifyRenderingInServerForm(Control control)
{
}
i dunno关于图表...抱歉
I am doing a project to show graph from excel file. the excel file is generated from the database.the input file in .csv format. and output file in .xls format.How can i do this by using PHP or .net or java , vb?
解决方案
this mite help you....
public static void ExportXls(GridView gridName, string filename) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + filename + ".xls"); HttpContext.Current.Response.Charset = ""; HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.ContentType = "application/Excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); gridName.RenderControl(htmlWrite); HttpContext.Current.Response.Write(stringWrite.ToString()); HttpContext.Current.Response.End(); }
The foll method is required in the page on which you want to export to excel...
public override void VerifyRenderingInServerForm(Control control) { }
i dunno about the graph...sorry
这篇关于如何从数据库中提取数据到excell文件并生成图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文