Let's assume I have following button code:
Ext.create('widget.button', {
handler: function () {
Ext.Ajax.request({
method: 'POST',
url: 'index.php?r=store/exportXLS',
params: {
queryName: me.exporting.name,
queryGroups: Ext.JSON.encode(me.exporting.groups)
},
success: function (response) {
//???
}
});
},
dock: 'top',
text: 'Экспорт в XLS'
});
Because groups
variable hold too much parameters, I must send all data via POST. Action "store/exportXLS" returns valid html which I want to save as XLS. I cannot use window.open()
because those windows are blocked everytime. So, question: is it possible to save response.responseText
as file? (Excel in my case)
UPDATE: As you requested, I post html.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="application/excel; charset=utf-8"/>
<title>hideshow</title>
</head>
<body>
<table border="1">
<thead>
<tr style="font-weight: bold">
<td>Пациент</td><td>Лекарственное средство</td>
</tr>
</thead>
<tbody>
<tr><td>Ажыфорафо А.В. <br />№ истории болезни: Х-34<br /></td><td>Аминокапроновая к-та р-р д/инф.5% фл.100мл Белмедпрепараты РУП,Республика Беларусь<br />Срок годности: 2016-01-01<br />Стоимость: 52.4700000<br />ЛС ОТМЕНЕНО<br /></td></tr>
</tbody>
</table>
</body>
</html>
With PHP I set headers as follows:
header("Content-Type: application/excel; charset=UTF-8");
header("Content-Disposition: attachment; filename=journal.xls");