注册 登录
编程论坛 ASP.NET技术论坛

把数据导入到固定的excl中

klfo 发布于 2007-04-06 11:17, 700 次点击
怎么把把数据导入到固定的excl中啊!?就是说比如d:盘中有一个已经做好的excl样式,里面都已经把每列的函数公式做好了,现在要把数据库中的一个或两个字段中的数据抓进去 怎么弄啊?
1 回复
#2
cyyu_ryh2007-04-06 12:41

这个只是简单导出,你可以在红色处修改下,具体没做过


#region 导出报表
protected void Button6_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "学生成绩报表.xls");


}
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView3.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}

public override void VerifyRenderingInServerForm(Control control)
{
//必须要
}

#endregion

1