2. I don't think the effect of the server to generate A.X LS file, directly in the form of a flow to the client and then download, how to achieve this?
3. The flow can be a byte, can also be a MemoryStream flow,
CodePudding user response:
How do you plan flow, the data is pass it on,CodePudding user response:
System. IO. MemoryStream ms=new System. IO. MemoryStream ();The book. Write (ms);//in written to the MemoryStream
Ms. Seek (0, SeekOrigin. Begin);
Byte [] bytelength=Ms. ToArray ();
Ms. Write (bytelength, 0, bytelength. Length);
Var filePath=Server. MapPath (tablename "~/excel/" + +". XLS ");
MainModels. WriteBuffToFile (bytelength filePath);//generates EXCEL file
Return the File (filePath, "application/VND. - ms excel," tablename + ". XLS ");
This is my current code is to survive EXCEL file first and then to the service side download EXCEL file, I don't like this way, I want to pass the flow directly output to the browser, and then download the EXCEL,
CodePudding user response:
If it is, can use the WebSocket,CodePudding user response:
Dizzy,you then!Byte [] bytelength=Ms. ToArray ();
Return the File (bytelength, "application/VND. - ms excel," tablename + ". XLS ");