Closed visualczm closed 2 years ago
Hi, Can you quickly describe a little bit more, what you want to do? Do you try to create workbooks on a web server (e.g. ASP.NET) and then to provide them by browser download? Thank you in advance for the information.
hi,
Do you try to create workbooks on a web server (e.g. ASP.NET) and then to provide them by browser download?
Yeah,but is .net5 webapi in web server ,i want return picoxlsx create file.
how did you do that?
Unfortunately, until now, I have not really worked with web servers in .net (had more to deal with Node and recently Java). However, from my Java experience, I could imagine that it should work like that:
Maybe I can do some research for this topic in the evening. I hope this helps in the meantime.
Maybe this could be the solution (if it is the right .net version): https://codeburst.io/download-files-using-web-api-ae1d1025f0a9 In this case, you could convert the MemoryStream into a byte array (https://docs.microsoft.com/en-us/dotnet/api/system.io.memorystream.toarray?view=net-5.0) and define the MIME type, as earlier described:
MemoryStream ms = new MemoryStream();
workbook.SaveAsStream(ms, true);
ms.Seek(0, SeekOrigin.Begin); // not sure whether this is necessary
byte[] bytes = ms.ToArray();
return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "workbook.xlsx");
Disclaimer: This is not tested code (just written down here in this comment)
I hope, this helps
Thank you so much~ Is worked
Hi, I'm come in , again~ See title,thank you for your help~