现在我用这个导出一个中继器(具有多重嵌套中继器)擅长:从中继器导出到Excel?
protected void ExportToExcel(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=finance.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
rptMinistry.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
但这不是做我想要的。相反,它是HTML给我的Excel文件(尽管数据有),这是我所得到的(每行是在Excel工作表单元格):
<tr class="alt">
<td class='hidden'>LOR In Development</td>
<td>MOD</td>
<td>Air Force</td>
<td class="size1"></td>
<td>Hellfire (AGM-114) Follow On</td>
<td>10-Mar-08</td>
<td class="align_right ">$50,000,000.00</td>
<td class="align_right hidden">$0.00</td>
</tr>
<tr class="alt">
<td class='hidden'>LOR In Development</td>
<td>MOD</td>
<td>Air Force</td>
<td class="size1"></td>
<td>Precision Strike Mi-17 (block 20)</td>
<td>17-May-08</td>
<td class="align_right ">$20,100,000.00</td>
<td class="align_right hidden">$0.00</td>
</tr>
等等...现在数据是正确的,但我怎样才能让它在电子表格中正确显示?
那么简单......不能相信我错过了,谢谢! – naspinski 2009-01-13 07:50:28