我的Jquery Php ajax调用在alert()函数中显示以下结果但是我希望将此输出作为ajax调用的excelsheet下载。我该怎么办?
<?xml version="1.0" encoding="UTF-8"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="semonExport Received Reports - ">
<Table>
<Row>
<Cell><Data ss:Type="String">semon RECEIVING REPORT</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String"> </Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">S/O</Data></Cell>
<Cell><Data ss:Type="String">SHIPPER</Data></Cell>
<Cell><Data ss:Type="String">NOTIFY PARTY</Data></Cell>
<Cell><Data ss:Type="String">INVOICE NO</Data></Cell>
<Cell><Data ss:Type="String">PO</Data></Cell>
<Cell><Data ss:Type="String">NG ITEM</Data></Cell>
<Cell><Data ss:Type="String">TOTAL LOT</Data></Cell>
<Cell><Data ss:Type="String">LOT RECEIVED</Data></Cell>
<Cell><Data ss:Type="String">PKGS</Data></Cell>
<Cell><Data ss:Type="String">QTY</Data></Cell>
<Cell><Data ss:Type="String">UNIT</Data></Cell>
<Cell><Data ss:Type="String">CBM</Data></Cell>
<Cell><Data ss:Type="String">Cweight</Data></Cell>
<Cell><Data ss:Type="String">Weight unit</Data></Cell>
<Cell><Data ss:Type="String">MSMT</Data></Cell>
<Cell><Data ss:Type="String">DEST</Data></Cell>
<Cell><Data ss:Type="String">STYLE</Data></Cell>
<Cell><Data ss:Type="String">R/CGO</Data></Cell>
<Cell><Data ss:Type="String">SB NO</Data></Cell>
<Cell><Data ss:Type="String">SB Date</Data></Cell>
<Cell><Data ss:Type="String">RECVDOC</Data></Cell>
<Cell><Data ss:Type="String">TOTAL VALUE</Data></Cell>
<Cell><Data ss:Type="String">EXP</Data></Cell>
<Cell><Data ss:Type="String">EXP DATE</Data></Cell>
<Cell><Data ss:Type="String">LOC</Data></Cell>
<Cell><Data ss:Type="String">REMARKS</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">marks</Data></Cell>
<Cell><Data ss:Type="String">Young One</Data></Cell>
<Cell><Data ss:Type="String">marks brothers</Data></Cell>
<Cell><Data ss:Type="String">1000</Data></Cell>
<Cell><Data ss:Type="String">marks</Data></Cell>
<Cell><Data ss:Type="String">nagroupbd</Data></Cell>
<Cell><Data ss:Type="String">1280</Data></Cell>
<Cell><Data ss:Type="String">200</Data></Cell>
<Cell><Data ss:Type="String">100</Data></Cell>
<Cell><Data ss:Type="String">100</Data></Cell>
<Cell><Data ss:Type="String">CARTONS</Data></Cell>
<Cell><Data ss:Type="String">583.2</Data></Cell>
<Cell><Data ss:Type="String">100</Data></Cell>
<Cell><Data ss:Type="String">Kgs</Data></Cell>
<Cell><Data ss:Type="String">180 X 180 X 180</Data></Cell>
<Cell><Data ss:Type="String">OKLAND</Data></Cell>
<Cell><Data ss:Type="String">marks</Data></Cell>
<Cell><Data ss:Type="String">Men's Product</Data></Cell>
<Cell><Data ss:Type="String">C 12908</Data></Cell>
<Cell><Data ss:Type="String">2016-02-02</Data></Cell>
<Cell><Data ss:Type="String">2016-02-02</Data></Cell>
<Cell><Data ss:Type="String">Max20</Data></Cell>
<Cell><Data ss:Type="String">2016-02-02</Data></Cell>
<Cell><Data ss:Type="String">ndsfjlsdajflka
dfasdf</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
我的Jquery ajax调用低于此类型代码
$(document).on("click","button[name=excelreceivedreports]",function() {
//alert("work");
url = getURL()+'/ajax/get_excelExport_receivedreports.php';
fdr = $('select[name=forwarder]').val();
frdt = $('input[name=fromdate]').val();
todt = $('input[name=todate]').val();
var data = "";
$('.plus-loader').animate({
'opacity': 1
},500);
$.post(url, {forwarder:fdr,fromdt:frdt,todate:todt },function(msg){
$('.plus-loader').animate({
'opacity': 0
},500);
alert(msg);
//$(".data-excel").html(msg);
});
});
您能告诉我如何将此警报消息转换为下载excel文件。我希望它在ajax电话上。提前谢谢。
答案 0 :(得分:0)
您可以添加一个按钮,将输出保存到Excel文件中。但为此,您的回复必须格式正确。例如:
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
e.preventDefault();
});
如果您不确定,请参阅this示例。