PDA

View Full Version : extjs excel



draminda
16 Dec 2013, 2:45 PM
hi all,
i need to crate some excel file which user can download i use extjs store to pass request to server but i dont know how to catch Excel file any sample code

my excel creation look likes

Workbook workbook2 = new HSSFWorkbook();
response.setContentType("application/vnd.ms-excel");
response.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
response.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=Report.xls");
response.addProperty(HttpHeaders.CONTENT_TYPE, " application/vnd.ms-excel");
response.addProperty(HttpHeaders.PRAGMA," no-cache");
response.addProperty(HttpHeaders.CACHE_CONTROL, "post-check=0, pre-check=0,false");
response.addProperty(HttpHeaders.CACHE_CONTROL, "no-store, no-cache, must-revalidate");
OutputStream out = response.getPortletOutputStream();
workbook2.write(out);
out.flush();
out.close();


sample store file

Ext.define( 'New.store.my', {
extend :'Ext.data.Store',
model : 'New.model.SupportModel',
autoLoad : true,
autoSync : true,
proxy : {
type : 'ajax',
url : ExcelUrl,
reader : {
type : 'json'
},
},

please help
best regards
raminda

scottmartin
16 Dec 2013, 4:08 PM
Just catch the success from the server an use open



$objWriter->save('xls/'.$reports_array['report_name'].'.xls');
echo "{success:true}";




Ext.Ajax.request({
method: 'POST',
url: 'create_excel.php',
params : {
// params to server
},
success: function(xhr) {
window.open('xls/' + employee_report_name + '.xls'); // opens report in browser
},
failure: function() {
}
});

draminda
16 Dec 2013, 10:34 PM
hi scottmartin,thx for the reply but i use Liferay portal (java servlet)please any idea ??

scottmartin
17 Dec 2013, 4:46 AM
Same premise .. your workbook2.write(out); is the same as save. The rest is JS on the client