コード例 #1
0
ファイル: excel.php プロジェクト: xflash8/staff-2016
<?php

//xls
if ($_GET['action'] == 'xlssasas') {
    global $wpdb;
    $q = "\r\n\t\tselect users.*, meta2.meta_value hp, meta3.meta_value NIY from {$wpdb->users} users\r\n\t\tleft join {$wpdb->usermeta} meta\r\n\t\ton meta.user_id = users.ID and meta.meta_key = 'pegawai'\r\n\t\tleft join {$wpdb->usermeta} meta2\r\n\t\ton meta2.user_id = users.ID and meta2.meta_key = '_hp'\r\n\t\tleft join {$wpdb->usermeta} meta3\r\n\t\ton meta3.user_id = users.ID and meta3.meta_key = 'niy'\r\n\t\twhere meta.meta_value is not null\r\n\t\torder by users.display_name ASC\r\n\t\t\r\n\t";
    $x = new Excel($wpdb->get_results($q));
    $x->setCols(array('NIY' => 'NIY', 'display_name' => 'Nama Lengkap', 'hp' => 'hp', 'user_email' => 'Email'));
    $x->setFilename('Daftar Pegawai STIBA Makassar');
    $x->display();
}
function ar_to_xls($ar)
{
    include get_template_directory() . '/classes/PHPExcel.php';
    /** PHPExcel_Writer_Excel2007 */
    include get_template_directory() . '/classes/PHPExcel/Writer/Excel2007.php';
    // Create new PHPExcel object
    $objPHPExcel = new PHPExcel();
    // Set properties
    $objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
    $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
    $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
    // determine table header from first row
    $c = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P');
    $c = range('A', 'Z');
    foreach ($c as $columnID) {
        $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
    }
    $col = array('NIY' => 'NIY', 'display_name' => 'Nama Lengkap', 'hp' => 'hp', 'user_email' => 'Email');