程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> jqGrid 導出excel表格代碼(php+jqgrid實例)

jqGrid 導出excel表格代碼(php+jqgrid實例)

編輯:關於PHP編程

jqgrid 導出excel表格代碼(php教程+jqgrid實例)
require_once '../../../tabs.php';
?>

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html>
  <head>
    <title>jqgrid php demo</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css教程" media="screen" href="../../../themes/redmond/jquery-ui-1.7.1.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="../../../themes/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="../../../themes/ui.multiselect.css" />
    <style type="text">
        html, body {
        margin: 0;            /* remove body margin/padding */
        padding: 0;
        overflow: hidden;    /* remove scroll bars on browser window */
        font-size: 75%;
        }
    </style>
    <script src="../../../網頁特效/jquery.網頁特效" type="text/網頁特效"></script>
    <script src="../../../js/i18n/grid.locale-en.js" type="text/網頁特效"></script>
    <script type="text/javascript">
    $.jgrid.no_legacy_api = true;
    $.jgrid.usejson = true;
    </script>
    <script src="../../../js/jquery.jqgrid.min.js" type="text/javascript"></script>
    <script src="../../../js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
  </head>
  <body>
      <div>
          <?php include ("grid.php");?>
      </div>
      <br/>
      <?php tabs(array("grid.php"));?>
   </body>
</html>

php代碼

<?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;
?>

 


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved