reactjs - Download to excel - Service Stack -
i have servicestack doing download excel below
$.ajax({ url: url, type: 'get', async: true, data: data, success: function (data) { var blob = new blob([datatest], { type: 'application/vnd.ms-excel' }); var downloadlink = document.createelement('a'); downloadlink.href = window.url.createobjecturl(blob); downloadlink.download = filename; downloadlink.style.display = 'none'; document.body.appendchild(downloadlink); downloadlink.click(); }, });
the data comes excel downloads in first column comma separated string.
i debugged observe [data] in code passed comma separated list , reason downloading in excel. like:
[data] = header1,header2,header3 data1,data2,data3 data4,data5,data6
if replace data table format excel download happens correctly. like:
[data]= <table> <tr> <td>1</td> <td>2</td> </tr> </table>
there 2 solutions thinking right now.
convert data table , use download.
do download excel in c# (service code)
which best solution (maybe other thinking) use in scenario.
Comments
Post a Comment