nas*_*ski 6 c# asp.net excel repeater
现在我用它来导出转发器(带有多个嵌套转发器)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();
}
Run Code Online (Sandbox Code Playgroud)
但这不是我想要的.相反,它在excel文件中给我html(虽然数据在那里)这是我得到的(每行是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>
Run Code Online (Sandbox Code Playgroud)
等等...现在数据是正确的,但我怎样才能让它在电子表格中正确显示?
Spe*_*ort 13
您需要将所有这些都包含在表标记中.Excel可以理解HTML表结构.
尝试:
Response.Write("<table>");
Response.Write(stringWrite.ToString());
Response.Write("</table>");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16320 次 |
| 最近记录: |