First, it can only be used under IE browser, because to invoke the Excel control, the other browser does not work;
Second, make changes to your browser's security settings:
Internet Options-security-custom security level-include a local directory path when uploading files to the server (enabled)
Internet Options-security-custom security level -Initialize and execute scripts for ActiveX controls that are not marked as safe to execute (enabled)
HTML page:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Upload to server:
UploadPost.aspx.cs
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using system.web.ui.webcontrols;using system.io;using newtonsoft.json;using Newtonsoft.json.linq;public partial class uploadpost:system.web.ui.page{ protected void Page_Load (object sender, EventArgs e) { string str = Request . form["Jsonstr"]; String str2 = ""; Jobject Jo = (jobject) jsonconvert.deserializeobject (str); for (int i = 0; i < jo["Rows"]. Count (); i++) {for (int j = 0; J < jo["Rows"][i]. Count (); J + +) { str2 + = jo["Rows"][i][j]; STR2 + = ""; } str2 + = "\ n"; } Response.Clear (); Response.ContentType = "Text/plain"; Response.Write (STR2); Response.End (); }}
JS reads and parses the Excel file, then uploads the JSON to the server