protected void btnPrint_Click(object sender, EventArgs e) { ExportDataTable Export = new ExportDataTable(); DataTable dt = GetDataTable(); Export.dataTable = dt; //不顯示的欄位 Export.DisableColumn.Add("uid"); string name = "個案轉介管理"; string time =""; if (txtBegCreateDate.Text != "" && txtEndCreateDate.Text != "") { time = "("+txtBegCreateDate.Text + "~" + txtEndCreateDate.Text+")"; } string Title = Export.GetTitle(name + time , 3); string ExportData = Title + Export.Render(); Util.OutputTxt(ExportData, "1", "個案轉介管理" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
//------------------------------------------------------------------------------ protected void btnPrint_Click(object sender, EventArgs e) { string 列印模式新增表頭 = ""; 列印模式新增表頭 += "<table><tr><td colspan=\"8\" style=\"font-size:24px;font-family:標楷體;width:100%;\">"; 列印模式新增表頭 += "志工服務紀錄表"; if (txtsDate.Text.Trim() != "" && txteDate.Text.Trim() != "") { 列印模式新增表頭 += "(" + txtsDate.Text.Trim() + "∼" + txteDate.Text.Trim() + ")"; } 列印模式新增表頭 += "統計"; 列印模式新增表頭 += "</td></tr></table>\n"; //原始的寫法,其實看不懂在寫甚麼 ExportDataTable Export = new ExportDataTable(); DataTable dt = GetDataTable("", ""); Export.dataTable = dt; Export.DisableColumn.Add("ColName"); string ExportData = Title + Export.Render(); string s = @"<head> <style> @page Section2 { size:841.7pt 595.45pt; mso-page-orientation:landscape; margin:1.5cm 0.5cm 0.5cm 0.5cm;} div.Section2 {page:Section2;} </style> </head> <body> <div class=Section2> ";//邊界-上右下左 StringBuilder sb = new StringBuilder(); sb.AppendLine(s); Util.OutputTxt(sb + 列印模式新增表頭 + Export.Render(), "1", "" + DateTime.Now.ToString("yyyyMMddHHmmss")); }