2016-03-23 18 views
0

Bir raporu php kullanarak vermeye çalışıyorum. localhost'ta iyi çalışır, ancak sunucuda çalıştırdığımda çalışmaz ve aşağıdakine benzer bir çıkış verir. (Burada gösterilmemiş olan tüm değişkenler, global olarak ilan edilir, bu yüzden değişken bildirimde bir sorun yoktur) .) çıkışı: ben denedimRaporunuzu exp'de php kullanarak dışa aktarırken, yerel olarak çalışıyor ancak sunucuda çalışmıyor mu?

enter image description here

Kod geçerli: kendim için

$arrayissue = array(); 

      $count = 0; 
      $screenshot_name = ''; 



      $cycle = $_SESSION['Cycle']; 
      $objPHPExcel = new PHPExcel(); 
      $query2 = "SELECT Cycle_name FROM cycle_master WHERE Cycle_id='$cycle'"; 
      $result2 = $conn->query($query2); 
      $row12 = mysqli_fetch_array($result2); 


      $ews = $objPHPExcel->getSheet(0); 
      $ews->setCellValue('a1', 'This is the Result For : ' . $row12[0]); 
      $rowCount = 2; 



      $title = 'a1:aj1'; 
      $header = 'a2:aj2'; 

      $objPHPExcel->getActiveSheet()->getStyle($title)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('A9F5E1'); 

      $objPHPExcel->getActiveSheet()->getStyle($header)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFF00'); 

      $style = array(
       'font' => array('bold' => true,), 
       'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,), 
      ); 

      $objPHPExcel->getActiveSheet()->getStyle($header)->applyFromArray($style); 
      $objPHPExcel->getActiveSheet()->getStyle(
        'A2:' . 
        $objPHPExcel->getActiveSheet()->getHighestColumn() . 
        $objPHPExcel->getActiveSheet()->getHighestRow() 
      )->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); 
      $objPHPExcel->getDefaultStyle()->getAlignment()->setWrapText(true); 
      $styleArray = array(
       'font' => array(
        'bold' => FALSE, 
        // 'color' => array('rgb' => 'FF0000'), 
        'size' => 10, 
        'name' => 'Calibri' 
      )); 
      $limit = $objPHPExcel->getActiveSheet()->getHighestDataColumn(); 
      echo $limit; 
      for ($col = 'A'; $col != $limit; $col++) { 

       $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setWidth(20); 
       $objPHPExcel->getActiveSheet()->getStyle($col)->applyFromArray($styleArray); 
      } 



      $queryforissue = "Select Issue_name from tmtool.project_issue_master where Project_id IN(Select Project_id from product_master Where Product_id='$productid')"; 
      $resultforissue = mysqli_query($conn, $queryforissue) or die(mysqli_error($conn)); 



      $countforissue = 0; 
      $customeTitle = array(); 
      $customTitle1 = array('Execution ID', 'TC ID', 'Partner Name', 'Product Name', 'Test URL', 'Issue'); 
      $customTitle2 = array('Circle Name', 'Mobile Number', 'Date', 'Time', 'Screen Shot Name', 'Comment'); 
      while ($rowissue = mysqli_fetch_array($resultforissue)) { 
       array_push($arrayissue, $rowissue['Issue_name']); 
       $countforissue++; 
      } 


      $customTitle3 = array_merge($customTitle1, $arrayissue); 
      $customTitle = array_merge($customTitle3, $customTitle2); 


      $alph = 'A'; 
      foreach ($customTitle as $value) { 
       $objPHPExcel->getActiveSheet()->SetCellValue($alph . $rowCount, $value); 
       $alph++; 
      } 
      $rowCount++; 

      if ($startdate != '' && $enddate != '') { 
       $queryresult = "SELECT testcase_master.`Testcase_id`,CONVERT(SUBSTRING_INDEX(testcase_master.`Testcase_id`,'_', -1),UNSIGNED INTEGER) as num ,testcase_master.`Testcase_title`,testcase_master.`Subscriber_type`,testcase_master.`Precondition`,testcase_master.`Activation_mode`,test_result_url.`Test_id`,test_result_url.`Assign_to`,test_result_url.`Circle_name`,test_result_url.`Performed_date`,test_result_url.`Status`,test_result_url.`Comment`,test_result_url.`Screen_shot_name`,test_result_url.`Device_used`,test_result_url.`Simcard_no`,test_result_url.`Time`,test_result_url.`Updated_date`,test_result_url.`Updated_time`,test_result_url.`Updated_by` FROM tmtool.test_result_url LEFT JOIN tmtool.testcase_master ON test_result_url.`Testcase_id`=testcase_master.`Testcase_id` WHERE testcase_master.`Product_id` = '$productid' AND (test_result_url.`Performed_date` BETWEEN '$startdate' AND '$enddate') AND testcase_master.`Testcase_id` IN (SELECT Testcase_id FROM assigned_testsuite_testcase WHERE Testsuite_id IN (SELECT Testsuite_id FROM testsuite_master WHERE Cycle_id = '$cycle')) order by num"; 
      } else { 
       $queryresult = "SELECT testcase_master.`Testcase_id`,CONVERT(SUBSTRING_INDEX(testcase_master.`Testcase_id`,'_', -1),UNSIGNED INTEGER) as num ,testcase_master.`Testcase_title`,testcase_master.`Subscriber_type`,testcase_master.`Precondition`,testcase_master.`Activation_mode`,test_result_url.`Test_id`,test_result_url.`Assign_to`,test_result_url.`Circle_name`,test_result_url.`Performed_date`,test_result_url.`Status`,test_result_url.`Comment`,test_result_url.`Screen_shot_name`,test_result_url.`Device_used`,test_result_url.`Simcard_no`,test_result_url.`Time`,test_result_url.`Updated_date`,test_result_url.`Updated_time`,test_result_url.`Updated_by` FROM tmtool.test_result_url LEFT JOIN tmtool.testcase_master ON test_result_url.`Testcase_id`=testcase_master.`Testcase_id` WHERE testcase_master.`Product_id` = '$productid' AND testcase_master.`Testcase_id` IN (SELECT Testcase_id FROM assigned_testsuite_testcase WHERE Testsuite_id IN (SELECT Testsuite_id FROM testsuite_master WHERE Cycle_id = '$cycle')) order by num"; 
      } 



      $resultquery = mysqli_query($conn, $queryresult) or die(mysqli_error($conn)); 



      while ($row = mysqli_fetch_array($resultquery)) { 
       $objPHPExcel->getActiveSheet()->SetCellValue('A' . $rowCount, $row['Test_id']); 
       $objPHPExcel->getActiveSheet()->SetCellValue('B' . $rowCount, $row['Testcase_id']); 
       $objPHPExcel->getActiveSheet()->SetCellValue('C' . $rowCount, $row['Precondition']); 
       $objPHPExcel->getActiveSheet()->SetCellValue('D' . $rowCount, $row['Activation_mode']); 
       $objPHPExcel->getActiveSheet()->SetCellValue('E' . $rowCount, $row['Testcase_title']); 
       $objPHPExcel->getActiveSheet()->SetCellValue('F' . $rowCount, $row['Status']); 


       for ($i = 0, $alpha2 = 'G'; $i < $countforissue; $i++, $alpha2++) { 

        $querygetResult = "Select $arrayissue[$i] from test_result_url where Test_id='$row[Test_id]'"; 
        $getResult = mysqli_query($conn, $querygetResult) or die('Error querying database'); 
        $rowResult = mysqli_fetch_array($getResult); 

        $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $rowResult[0]); 
       } 

       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Circle_name']); 
       $alpha2++; 
       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Simcard_no']); 
       $alpha2++; 
       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Performed_date']); 
       $alpha2++; 
       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Time']); 
       $alpha2++; 
       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Screen_shot_name']); 
       $alpha2++; 
       $objPHPExcel->getActiveSheet()->SetCellValue($alpha2 . $rowCount, $row['Comment']); 


       $rowCount++; 
      } 

      unset($alpha2); 
      $objPHPExcel->getActiveSheet()->setTitle("Product Wise"); 
      header('Content-Type: application/vnd.openxmlformats- officedocument.spreadsheetml.sheet'); 
      header('Content-Disposition: attachment;filename="TestResults.xlsx"'); 
      header('Cache-Control: max-age=0'); 

      $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); 
      ob_end_clean(); 
      $objWriter->save('php://output'); 
+0

çıktı nedir. herhangi bir hata aldın mı? Dosyanızın en üstünde 'error_reporting (E_ALL);' ve 'ini_set ('display_errors', 1);' ayarlamaya çalışın. – vaso123

+0

Çıktının görüntüsünü ekledim lütfen kontrol edin –

+0

Sunucudaki klasörde yazma izniniz var mı? Değiştirmek için chmod'u dene. –

cevap

1

Bulunan cevap.

1) bir yankı ifade mevcut kaldırma header.so için A 'gönderir var olduğunu yankı ob_end_clean
2)() i bu kod, iyi iş kaldırdık olduğunda sorun yaratmaktadır.

Bana yardım etmeye çalışan herkese teşekkürler.

İlgili konular