在后台直接读取excel文件转成FileStream文件流,通过jsonData将文件流传回给js,
但是js用spread.fromJSON(XX)的方式绑定不了值,请问还有其他方式将值绑定到spread吗
(该代码时参考了ExcelIOSample中的导入excel)
//控制器层
public JsonResult getShareResultTemp()
{
//初始化加载模板
String result = "";
try
{
//读取webconfig中的上传文件路径
string strConfig = System.Configuration.ConfigurationManager.AppSettings["Templates"];
//转换成绝对路径
string strPath = HttpContext.Server.MapPath(strConfig + "/分摊表.xlsx");
//var file = Request.Files[0];
FileStream inputStream = new FileStream(strPath, FileMode.OpenOrCreate);
Console.WriteLine(inputStream);
Importer importer = new Importer();
//result = importer.ImportExcel(file.InputStream, flags, password);
result = importer.ImportExcel(inputStream);
importer = null;
result = HttpUtility.HtmlEncode(result);
}
catch (Exception ex)
{
throw ex;
}
var jsonData = new
{
result = result
};
return LargeJson(jsonData, JsonRequestBehavior.AllowGet);
}
//js
function success(oResult) {
$("#ss").empty();
//获取当前spread
//var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"));
console.log(oResult.result);
var spread = $("#ss").data("spread");
spread.fromJSON(oResult.result);
}
|
|