2016-08-19 60 views

回答

0

您可以使用<table>來顯示錶格。閱讀EXCELL文件作爲這個例子

enter code hereinclude 'Classes/PHPExcel/IOFactory.php'; 

$inputFileName = 'index.xlsx'; 

// Read your Excel workbook 
try { 
    $inputFileType = PHPExcel_IOFactory::identify($inputFileName); 
    $objReader = PHPExcel_IOFactory::createReader($inputFileType); 
    $objPHPExcel = $objReader->load($inputFileName); 
} catch (Exception $e) { 
    die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) 
     . '": ' . $e->getMessage()); 
} 

// Get worksheet dimensions 
$sheet = $objPHPExcel->getSheet(0); 
$highestRow = $sheet->getHighestRow(); 
$highestColumn = $sheet->getHighestColumn(); 

// Loop through each row of the worksheet in turn 
for ($row = 1; $row <= $highestRow; $row++) { 
    // Read a row of data into an array 
    $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, 
     NULL, TRUE, FALSE); 

然後將這些數據添加到您的HTML表,它是依賴於你的表requrement。這只是一些介紹。如果你有任何問題,在這裏評論

0

,如果我使用此代碼顯示從數據庫中的數據,

function reportExcel() 
{ 
    $user = $this->session->userdata('username');//user print 
    $awal = $this->input->post('tglawal');//tanggal awal 
    $akhir = $this->input->post('tglakhir');//tanggal akhir 
    $suplier = $this->input->post('suplier');//suplier 
    $userord = $this->input->post('userord');//suplier 
    $ket = $this->input->post('ket');//keterangan 
    $status = $this->input->post('status');//status 
    $query = 'select * from porder where tgl_po >= "'.$awal.'" and tgl_po <= "'.$akhir.'" and lower(suplier) like ("%'.$suplier.'%") and lower(username) like lower("%'.$userord.'%") and lower(status) like lower("%'.$status.'%") and lower(keterangan) like lower("%'.$ket.'%") '; 
    if ($result = mysql_query($query)) { 
     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
     echo "<pre>"; 
     echo $row['no_po']; 
     $query_det = "SELECT * FROM pordet a, preq b WHERE a.no_req = b.no_req and a.no_po ='".$row["no_po"]."'"; 
     // BAGIAN 2 
      $result_det = mysql_query($query_det); 
       while ($rowdet = mysql_fetch_array($result_det, MYSQL_ASSOC)) { 
       echo $rowdet['no_req']; 
     //BAGIAN 3 
       } 

     } 
    } 
} 

相關表格要求

那麼如何把數據放到任何Orders表數據PHPExcel上的表格順序數據請求後的表格如上圖