"); + foreach (DataColumn column in dt.Columns) + { + sb.Append(" | " + column.ColumnName + " | "); + } + sb.Append("
" + ((int)(j + 1)).ToString() + " | "); + for (int k = 0; k <= iColsCount - 1; k++) + { + sb.Append(""); + object obj = dt.Rows[j][k]; + if (obj == DBNull.Value) + { + obj = " ";//如果是NULL则在HTML里面使用一个空格替换之 + } + if (obj.ToString() == "") + { + obj = " "; + } + string strCellContent = obj.ToString().Trim(); + sb.Append("" + strCellContent + ""); + sb.Append(" | "); + } + sb.Append("