private string ExportHtml(DataTable dt)
{
StringBuilder strHTMLBuilder = new StringBuilder();
strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("");
strHTMLBuilder.Append("
");
strHTMLBuilder.Append(" ");
foreach (DataColumn myColumn in dt.Columns)
{
strHTMLBuilder.Append("
");
strHTMLBuilder.Append(myColumn.ColumnName);
strHTMLBuilder.Append("
");
}
strHTMLBuilder.Append("
");
foreach (DataRow myRow in dt.Rows)
{
strHTMLBuilder.Append(" ");
foreach (DataColumn myColumn in dt.Columns)
{
strHTMLBuilder.Append("
");
strHTMLBuilder.Append(myRow[myColumn.ColumnName].ToString());
strHTMLBuilder.Append("
");
}
strHTMLBuilder.Append("
"); }
//Close tags.
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
");
string Htmltext = strHTMLBuilder.ToString();
return Htmltext;
}
沒有留言:
張貼留言