导出Excel问题,流跟json数据的转换问题?
前台:<input id="InsertToExcel_btn" type="button" value="导出Excel" class="btn"/>
//导出Excel功能 function inserToExcelBtnClick() { var sendID = ""; var url = "ToExcel.action"; for (var i = 0; i < count; i++) { sendID = sendID + ";" + treeNodeID[i]; } sendID = sendID.slice(1); alert(sendID); $.post(url, { "type": mappingType, "list": sendID }, function() { }, "json"); };
MemoryStream ms = NPOIHelper.ToExcel(RequirementDetailForXls) as MemoryStream; context.Response.AddHeader("Content-Disposition", ("attachment;filename=" + filename)); context.Response.Charset = "UTF-8"; context.Response.ContentType = "application/json"; context.Response.BinaryWrite(ms.ToArray()); ms.Close(); ms.Dispose();
$.post(url, { "type": mappingType, "list": sendID }, function() { }, "json");
[解决办法]
src长度限制2046字节,个人测试2020长度极限(IE)
HTML5貌似增加了新的通信对象,支持服务器 推,目前没有研究,你可以看看