- 注册时间
- 2017-1-3
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 198
- 精华
- 0
- 帖子
- 48
|
felt 发表于 2018-1-31 09:30
导出excel我们做的只是将表头数据传递到后台,具体导出怎么样的excel是你后台操作专门的类来控制的。 ...
public void exportExcel(ArrayList columns, ArrayList data, string dpt_name)
{
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
//Response.Charset = "UTF-8";
if (dpt_name == null)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMM") + "库存" + ".xls");
}
else
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMM") + dpt_name + "库存" + ".xls");
}
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
EnableViewState = false;
Response.Write(exportTable(data, columns));
Response.End();
}
public static ArrayList getColumnsBottom(ArrayList columns)
{
ArrayList columnsBottom = new ArrayList();
for (int i = 0; i < columns.Count; i++)
{
Hashtable column = (Hashtable)columns;
if (column["columns"] != null)
{
ArrayList childColumns = (ArrayList)column["columns"];
columnsBottom.AddRange(getColumnsBottom(childColumns));
}
else
{
columnsBottom.Add(column);
}
}
return columnsBottom;
}
public static ArrayList getColumnsTable(ArrayList columns)
{
ArrayList table = new ArrayList();
getColumnsRows(columns, 0, table);
createTableSpan(table);
return table;
} |
|