Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sun Sep 21, 2014 11:56 am

I have the need to:
1) send a json request to a service webapi2
2) the service must reply by sending me an xls file (without having to save the file on the server)

how can I achieve my goal?

I tried to use to write the following but does not work. What's wrong ?:

Result = New HttpResponseMessage(Net.HttpStatusCode.OK)
Dim test As StreamContent = New StreamContent(FileResult)
Result.Content = New StreamContent(FileResult)
Result.Content.Headers.Add("Content-Type", "application/xls")
Result.Content.Headers.Add("Content-Disposition", "attachment; filename=" + "sample.xls")
Result.Content.Headers.ContentType = New Headers.MediaTypeHeaderValue("application/octet-stream")

Thanks in advance

Luca

lucagiovanni
 
Posts: 12
Joined: Thu Aug 14, 2014 6:59 am

Mon Sep 22, 2014 3:43 am

Hello,

Sorry for late reply as weekend.
Thanks for your inquiry.
I'm afraid that we can't provide you any solution about the first step as sending a json request to a service. And our Spire.xls supports the feature to save a xls file to Response instead of saving the file on the server.
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromStream(Stream stream);
workbook.SaveToHttpResponse(string FileName, System.Web.HttpResponse response, HttpContentType httpContextType);

If you have any questions or need further help, feel free to contact us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Sep 25, 2014 9:36 am

Hello,

Has the issue been resolved? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Sep 29, 2014 2:22 pm

Hello Gary,
thanks for your reply,
I solved it by sending to the controller a hidden form with method "POST".
the response is an object of type HttpResponseMessage containing the stream file generated through Spire.XLS.

lucagiovanni
 
Posts: 12
Joined: Thu Aug 14, 2014 6:59 am

Thu Oct 02, 2014 1:46 am

Hello,

Thanks for your response. If you have any questions or need further help, feel free to contact us.
Sincerel,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS