在移动设备中打开时,导出到excel不起作用。 Asp.net MVC4 [英] Export to excel not working when open in mobile. Asp.net MVC4
本文介绍了在移动设备中打开时,导出到excel不起作用。 Asp.net MVC4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此处 我的代码
ExportedTable = < table>< th>< / th>名称< th>< / th>< th>移动< / th>< th> Adress< / th> < tr>< td> XYZ< / td>< td> 123456789< / td>< td> XYZ< / td>< / tr>< / table>;
Response.Clear();
Response.Buffer = true ;
Response.AddHeader( content-disposition, attachment; filename = Overview.xls);
Response.Charset = ;
Response.ContentType = application / vnd.ms-excel;
string style = @ < style> ; TABLE {border:thin solid black;} TD {border:thin solid black;}< / style>;
Response.Write(style);
Response.Output.Write(ExportedTable.ToString());
Response.Flush();
Response.End();
现在它的工作正常在 windows browser 当 i导出数据时在移动设备中,它在 excel文件中提供HTLM 。
我遇到 此问题如何解决这个?
我尝试过:
导出到excel在移动设备中打开时不起作用。
解决方案
您没有创建Excel文件,只是发送HTML
使用XLS
文件扩展名,移动设备上的Excel与桌面不同,并且没有检测输入和读取等所有功能无论你给它什么。
尝试创建真正的XLSX
文件: EPPlus-在服务器上创建高级Excel电子表格 - 主页 [ ^ ]
Here is my code
ExportedTable = "<table><th></th>Name<th></th><th>Mobile</th><th>Adress</th> <tr><td>XYZ</td><td>123456789</td><td>XYZ</td></tr> </table>";
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=Overview.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
string style = @"<style> TABLE { border: thin solid black; } TD { border: thin solid black; } </style> ";
Response.Write(style);
Response.Output.Write(ExportedTable.ToString());
Response.Flush();
Response.End();
Now its work fine in windows browsers when i export data in mobile its give HTLM in excel file.
I am stuck in this problem how to resolve this?
What I have tried:
Export to excel not working when open in mobile.
解决方案
You are not creating an Excel file, you are just sendingHTML
with theXLS
file extension, Excel on mobile is not like desktop and does not have all the features like detecting the input and reading whatever you give it.
Try creating realXLSX
files with : EPPlus-Create advanced Excel spreadsheets on the server - Home[^]
这篇关于在移动设备中打开时,导出到excel不起作用。 Asp.net MVC4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文