asp.net导出excel问题

protected void btnWTBExport_Click(object sender, EventArgs e)
{
    try
    {
        //1普通工单 下的业务工单
        string strExportFiled = string.Empty;
        string strCodeTypeName = string.Empty;
        string strEmptyText = string.Empty;
        if (hidExportType.Value == "1")
        {
            strExportFiled = hidWTExportFiled.Value;
            strEmptyText = hidWTExportFiledName.Value;
            //字段字符串集合
            string strNewItems = strExportFiled.TrimEnd(',');
            if (!string.IsNullOrEmpty(strNewItems))
            {
                //文字描述集合
                string strNewText = strEmptyText.TrimEnd(',');

                string[] strStrNewItems = strNewItems.Substring(0, strNewItems.IndexOf('|')).Split(',');
                string[] strStrNewText = strEmptyText.Substring(0, strEmptyText.Length - 1).Split(',');
                DataTable dt1 = ExportWTBusinessData(strNewItems.Substring(0, strNewItems.IndexOf('|')), strStrNewText).Tables[0];

                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    //导出Excel
                    new NpoiFileOper().DataTable2Excel(dt1, "sheet1", "工单业务导出" + DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                }
                else
                {
                    return;
                }
            }
        }
    }
    catch (Exception err)
    {

    }

}
    问下这个导出的是什么表里的数据啊

这个看不出来导出的是什么内容表,可以查看下ExportWTBusinessData,这个方法和参数,这个方法就是返回内存数据表DataTable,再通过调用NPOI组件导出成文件。

不太明白你什么意思,你是想把数据库中的数据导出到excel表吗?

ASP.NET导出数据先要进行一个数据查询,这个方法只能说是将查询到的数据导出,并没有进行查询,那又如何获悉所查询的数据呢?

DataTable dt1 = ExportWTBusinessData(strNewItems.Substring(0, strNewItems.IndexOf('|')), strStrNewText).Tables[0];
去查看ExportWTBusinessData这个方法的定义,怎么读取数据库的

跳转到 这个 ExportWTBusinessData 方法 应该就可以知道了