EasyUI Forum
May 21, 2024, 03:35:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: export to excel  (Read 29854 times)
vuras
Newbie
*
Posts: 3


View Profile Email
« on: May 07, 2013, 01:42:15 AM »

Hi,  I was wondering about creating a button to export easyui datagrid to excel file. Is there a way?
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #1 on: May 07, 2013, 02:47:04 AM »

Hi,

Check this https://github.com/PHPOffice/PHPExcel

It seems very friendly. I use it for couple of years already.

And yes, I have special "Excel" export button on my DataGrid and TreeGrid.
Logged
vuras
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: May 07, 2013, 09:02:23 AM »

thanks, for your response and help. Maybe you could put me into right direction by showing one of your examples how to implement this plugin with easyui datagrid?
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #3 on: May 08, 2013, 06:01:03 AM »

Lots of PHPExcel example could be found here: https://github.com/PHPOffice/PHPExcel/tree/develop/Examples

On client side I have the following code:

Code:
function myButtonClick(){
getFile('phpExcelTest.php',$("#myForm").serialize());
}

function getFile(address,parameters){
$.messager.progress({text:'Processing. Please wait...'});
$.post(address,
parameters,
function(data){
$.messager.progress('close');
if(isNaN(data)==false){
javascript:window.location='getFile.php?p='+data;
} else {
$.messager.alert('ERROR',data);
}
}
);
}

In my case PHP script generates/saves file and sends its integer ID back to getFile function.
If I get integet value than it is OK and I could call for already generated file ohtervise show message from PHP script.

If you 100% sure that your Excel file will be generated without any problems you can call for Excel file directly via "javascript:window.location=" for example
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!