protected void btn_output_Click(object sender, EventArgs e)
{
//OutPutByGridview();
PanelOutput();
}
private void PanelOutput()
{
DataSet ds = u.GetOutTableData("");
if(ds != null && ds.Tables[0].Rows.Count !=0)
{
//加表头
HtmlTableRow trhead = new HtmlTableRow();
for (int k = 0; k < ds.Tables[0].Columns.Count; k++)
{
HtmlTableCell tchead = new HtmlTableCell();
tchead.InnerText = ds.Tables[0].Columns[k].ColumnName;
trhead.Cells.Add(tchead);
}
this.tbout.Rows.Add(trhead);
//表的内容
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
HtmlTableRow tr = new HtmlTableRow();
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
HtmlTableCell tc = new HtmlTableCell();
tc.InnerText = ds.Tables[0].Rows[i][j].ToString();
//switch (j)
//{
// case 0:
// tc.InnerText = ds.Tables[0].Rows[i]["name"].ToString();
// break;
// case 1:
// tc.InnerText = ds.Tables[0].Rows[i]["Age"].ToString();
// break;
// case 2:
// tc.InnerText = ds.Tables[0].Rows[i]["Sex"].ToString();
// break;
// default:
// break;
//}
tr.Cells.Add(tc);
}
this.tbout.Rows.Add(tr);
}
}
Comm.OutPutExcel(plOut3);
}