public static void DownData(DataView dvData, string fileName)
{
StringBuilder strBd = new StringBuilder(EXCELHTMLHEAD + "<table x:str><tr>");
int cols = dvData.Table.Columns.Count;
for (int j = 0; j < cols; j++)
strBd.Append("<td>" + dvData.Table.Columns[j].Caption + "</td>");
strBd.Append("</tr>");
for (int i = 0; i < dvData.Count; i++)
{
strBd.Append("<tr>");
for (int j = 0; j < cols; j++)
strBd.Append("<td>" + Lixiang.Common.HtmlToTxt(Convert.ToString(dvData[i][j])) + "</td>");
strBd.Append("</tr>");
}
strBd.Append("</table></body></html>");
DownData(strBd.ToString(), fileName);
}
public const string EXCELHTMLHEAD = @"<html xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='
http://www.w3.org/TR/REC-html40'>
<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>ExportData</x:Name><x:WorksheetOptions><x:Selected/></x:WorksheetOptions>
</x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
</head><body>";