是用MVC上传下载Excel,并使用SpreadJS显示
- // GET: Home
- public ActionResult Index()
- {
- if (Request.Files != null && Request.Files.Count > 0)
- {
- var file = Request.Files[0];
- Importer excelImport = new Importer();
- var text = excelImport.ImportExcel(file.InputStream);
- ViewBag.ExcelJson = text;
- }
- return View();
- }
-
- [HttpPost]
- public ActionResult ExportFile(string jsonString)
- {
- Exporter excelExporter = new Exporter(jsonString);
- excelExporter.SaveExcel(Response.OutputStream);
- Response.AddHeader("content-disposition", "attachment; filename= test.xlsx");
- Response.End();
- return View();
- }
复制代码
02SpreadJSExcelIO.zip
(9.17 MB, 下载次数: 1355)
|
|