Rumah  >  Artikel  >  php教程  >  jqGrid 导出excel表格代码(php+jqgrid实例)

jqGrid 导出excel表格代码(php+jqgrid实例)

WBOY
WBOYasal
2016-06-13 11:24:042177semak imbas

jqgrid 导出excel表格代码(php教程+jqgrid实例)
require_once '../../../tabs.php';
?>



 


    jqgrid php demo
   
   
   
   
   
   
   
   
   
   
 
 
     

         
     

     

     
  

php代码

require_once '../../../jq-config.php';
// include the jqgrid class
require_once abspath."php/jqgrid.php";
// include the driver class
require_once abspath."php/jqgridpdo.php";
// connection to the server
$conn = new pdo(db_dsn,db_user,db_password);
// tell the db that we use utf-8
$conn->query("set names utf8");

// create the jqgrid instance
$grid = new jqgridrender($conn);
// write the sql query
$grid->selectcommand = 'select orderid, orderdate, customerid, freight, shipname from longorders';
// set the ouput format to json
$grid->datatype = 'json';
// let the grid create the model
$grid->setcolmodel();
// set the url from where we obtain the data
$grid->seturl('grid.php');
$grid->optimizesearch = true;
// set some grid options
$grid->setgridoptions(array("rownum"=>100,"sortname"=>"orderid","height"=>150));
// change some property of the field(s)
$grid->setcolproperty("orderdate", array(
    "formatter"=>"date",
    "formatoptions"=>array("srcformat"=>"y-m-d h:i:s","newformat"=>"m/d/y"),
    "search"=>false
    )
);
// enable toolbar searching
$grid->toolbarfilter = true;
$grid->setfilteroptions(array("stringresult"=>true));
// enjoy
$grid->rendergrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>

 


Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:php图片文件上传实例代码Artikel seterusnya:php上传大文件设置方法