Export-To-Excel -- how to specify the response type in angular $resource to receive an excel file on the front end.

845 views
Skip to first unread message

Ravi Goli

unread,
Sep 12, 2013, 12:35:56 PM9/12/13
to ang...@googlegroups.com
I am trying return an excel document as below from my back-end rest-service code. and I am able to create an excel file (using POI) and even read the file and verify the response in fiddler. But I am not able to display a pop-up or display the excel in the front-end. I am using angular in the front-end.
 

@PUT
@Produces("application/vnd.ms-excel")

The below is the angular code:

surveySvcModule.factory('exportExcelCompleteSurvey', function($resource){
 return $resource('/traits/rest/US/wm/survey/generateExcelForCompleteSurvey', {}, {
  exportToExcel: {method:'PUT'}
 });
});

Does someone have an idea on how to define in $resource, the responseType or the contentType?

Thanks much for ur time.

Ravi

 

 

Goli

unread,
Sep 13, 2013, 1:27:34 AM9/13/13
to ang...@googlegroups.com
I still didn't get lucky in solving this...am a newbie to angular...
any comments on how to have angular define the "return/response/content type" as "excel" in the $resource???
 
Thx Much....

Luke Kende

unread,
Sep 14, 2013, 1:42:34 AM9/14/13
to ang...@googlegroups.com
I am pretty sure you are trying to fit a square block into a round hole.  $resource objects expect json by default, but you can specify the responseType in the latest Angular.  If I had to deal with Excel files, it would be server-side only, transforming any data to json for passing to and from the client.  
Reply all
Reply to author
Forward
0 new messages