如何在Asp.net C#中创建空白Excel工作表 [英] How to create blank Excel sheet in Asp.net C#
本文介绍了如何在Asp.net C#中创建空白Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在asp.net中以编程方式创建空的excel文件
I want to create only empty excel file using programmatically in asp.net
推荐答案
嗨
我认为这可能会有所帮助。
Hi
I think this may help u
public void ExportTableData(DataTable dtdata)
{
string attach = "attachment;filename=Sample.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attach);
Response.ContentType = "application/ms-excel";
if (dtdata != null)
{
// foreach (DataColumn dc in dtdata.Columns) // if u need to add data uncomment this
// {
// Response.Write(dc.ColumnName + "\t");
//}
// Response.Write(System.Environment.NewLine);
// foreach (DataRow dr in dtdata.Rows)
//{
// for (int i = 0; i < dtdata.Columns.Count; i++)
// {
// Response.Write(dr[i].ToString() + "\t");
// }
// Response.Write("\n");
}
Response.End();
}
}
这篇关于如何在Asp.net C#中创建空白Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文