Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.net html表格导出到excel_Asp.net_Html Table_Export To Excel - Fatal编程技术网

ASP.net html表格导出到excel

ASP.net html表格导出到excel,asp.net,html-table,export-to-excel,Asp.net,Html Table,Export To Excel,我使用这种方式导出excel,但没有显示任何数据。如何修复它?或者,还有其他出口方式吗 protected void exportExcel_Click(object sender, EventArgs e) { Response.ContentType = "application/x-msexcel"; Response.AddHeader("Content-Disp

我使用这种方式导出excel,但没有显示任何数据。如何修复它?或者,还有其他出口方式吗

protected void exportExcel_Click(object sender, EventArgs e)
 {  
   Response.ContentType = "application/x-msexcel";                                                      
   Response.AddHeader("Content-Disposition", "attachment;filename = ExcelFile.xls");
   Response.ContentEncoding = Encoding.UTF8;                                                                     
   StringWriter tw = new StringWriter();                                                                   
   HtmlTextWriter hw = new HtmlTextWriter(tw);
   table.RenderControl(hw);
   Response.Write(tw.ToString());                                                                   
   Response.End();
 }

$(文档).ready(函数(){
$.ajax({
url:'WebService.asmx/GetFees',
方法:“post”,
数据类型:“json”,
成功:功能(数据){
对于(var count=0;count

支出
月
2018/1
2018/2
2018/3
2018/4
2018/5
2018/6
2018/7
2018/8
2018/9
2018/10
2018/11
2018/12
电费
材料费

FYI:Excel文件不是文本或html文件。嗨,Alex,谢谢你的回答。上次我使用table2excel.js导出。