本文介绍了将数据写入excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有在Excel文件中写入的gridview数据.它的功能是,
i have gridview data that i write in the excel file. its function is as,
protected void btnExportToExcel_Click(object sender, EventArgs e)
{
try
{
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "EmployeeAttendance.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvDisplayRecords.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception ex)
{
lblEmpAttError.Text = "" + ex.Message;
}
}
现在我想在此gridview数据下写一行.
now i want to write single line under this gridview data. for the total days employee present and absent how can i write it.
推荐答案
Response.Write(sw.ToString());
只需在执行Response.End()之前将所需的内容添加到Response.Write()中即可.
just add whatever you need into the Response.Write() before you do the Response.End().
这篇关于将数据写入excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!