使用codeigniter设置坐标phpexcel

时间:2016-08-19 04:01:09

标签: php mysql codeigniter phpexcel

how to set cordinate like this if data from database

我有两个表:表顺序,表请求 我想在图片中显示表格 请求表是表顺序的主键 我该如何确定PHPExcel上的坐标 感谢您的帮助

2 个答案:

答案 0 :(得分: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表格中,这取决于您的表格需求。这只是一些介绍。如果您有任何问题请在此处发表评论

答案 1 :(得分: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
                 }

        }
    }
}

订单表中与表格请求相关的任何数据

然后如何在PHPExcel上的表顺序中的数据请求之后将数据放在表上,如上图所示