我在codeigniter php中的excel表中下载数据时遇到错误。当数据更多时,错误就越来越多。有人可以帮我修复错误。
我得到的错误如下:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: PHPExcel/Worksheet.php
Line Number: 1674
下面是代码
for($q = 0,$x = 0;$q < count($data['question']),$x < count($data['details']);$q++,$x++)
{
$z = 0;
foreach ($data['details'] as $key => $value)
{
$letter = "C";
$letter_rating = "B";
$k= 4 + $z;
for($i = 0;$i< count($data['details'][$x]);$i++)
{
if($data['details'][$x][$i]['rating'] == 1)
{
foreach ($data['selected_demo'] as $value1)
{
for($m = 0;$m < count($data['demo_statements']);$m++)
{
if ($value1 == $data['demo_statements'][$m]->demo_question_no)
{
//echo "value ".$value1;
//echo "question_no ".$data['demo_statements'][$m]->demo_question_no;
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['demo_statements'][$m]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['demo_statements'][$m]->traditional_chinese_answer;
}
else if($language == 3){
$answer =$data['demo_statements'][$m]->english_answer;
}
$thead = explode("_",$answer);
//echo '<pre>';print_r($value[$m]);
for($t = 0;$t < count($thead);$t++)
{
//echo $m;
//echo $data['details'][$x][$i][$thead[$t]];
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
// exit;
for($a = 0;$a < count($data['extra_demo']);$a++)
{
if($value1 == $data['extra_demo'][$a]->demo_id)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['extra_demo'][$a]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['extra_demo'][$a]->traditional_chinese_answer;
}
else if($language == 3){
$answer = $data['extra_demo'][$a]->english_answer;
}
$thead = explode("_",$answer);
//echo count($thead);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
}
}
}
//exit;
$letter = "C";
$letter_rating = "B";
$k= 5 + $z;
for($i = 0;$i< count($data['details'][$x]);$i++)
{
if($data['details'][$x][$i]['rating'] == 2)
{
foreach ($data['selected_demo'] as $value1)
{
for($m = 0;$m < count($data['demo_statements']);$m++)
{
if ($value1 == $data['demo_statements'][$m]->demo_question_no)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['demo_statements'][$m]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['demo_statements'][$m]->traditional_chinese_answer;
}
else if($language == 3){
$answer =$data['demo_statements'][$m]->english_answer;
}
$thead = explode("_",$answer);
//echo count($thead);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
for($a = 0;$a < count($data['extra_demo']);$a++)
{
if($value1 == $data['extra_demo'][$a]->demo_id)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['extra_demo'][$a]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['extra_demo'][$a]->traditional_chinese_answer;
}
else if($language == 3){
$answer = $data['extra_demo'][$a]->english_answer;
}
$thead = explode("_",$answer);
//echo count($thead);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
}
}
}
//exit;
$letter = "C";
$letter_rating = "B";
$k =6 + $z;
for($i = 0;$i< count($data['details'][$x]);$i++)
{
if($data['details'][$x][$i]['rating'] == 3)
{
foreach ($data['selected_demo'] as $value1)
{
for($m = 0;$m < count($data['demo_statements']);$m++)
{
if ($value1 == $data['demo_statements'][$m]->demo_question_no)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['demo_statements'][$m]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['demo_statements'][$m]->traditional_chinese_answer;
}
else if($language == 3){
$answer =$data['demo_statements'][$m]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
for($a = 0;$a < count($data['extra_demo']);$a++)
{
if($value1 == $data['extra_demo'][$a]->demo_id)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['extra_demo'][$a]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['extra_demo'][$a]->traditional_chinese_answer;
}
else if($language == 3){
$answer = $data['extra_demo'][$a]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
}
}
}
$letter = "C";
$k = 7 + $z;
for($i = 0;$i< count($data['details'][$x]);$i++)
{
if($data['details'][$x][$i]['rating'] == 4)
{
foreach ($data['selected_demo'] as $value1)
{
for($m = 0;$m < count($data['demo_statements']);$m++)
{
if ($value1 == $data['demo_statements'][$m]->demo_question_no)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['demo_statements'][$m]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['demo_statements'][$m]->traditional_chinese_answer;
}
else if($language == 3){
$answer =$data['demo_statements'][$m]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
for($a = 0;$a < count($data['extra_demo']);$a++)
{
if($value1 == $data['extra_demo'][$a]->demo_id)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['extra_demo'][$a]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['extra_demo'][$a]->traditional_chinese_answer;
}
else if($language == 3){
$answer = $data['extra_demo'][$a]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
}
}
}
$letter = "C";
$k = 8 + $z;
for($i = 0;$i< count($data['details'][$x]);$i++)
{
if($data['details'][$x][$i]['rating'] == 5)
{
foreach ($data['selected_demo'] as $value1)
{
for($m = 0;$m < count($data['demo_statements']);$m++)
{
if ($value1 == $data['demo_statements'][$m]->demo_question_no)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['demo_statements'][$m]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['demo_statements'][$m]->traditional_chinese_answer;
}
else if($language == 3){
$answer =$data['demo_statements'][$m]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
for($a = 0;$a < count($data['extra_demo']);$a++)
{
if($value1 == $data['extra_demo'][$a]->demo_id)
{
if(isset($_POST['language'])){
$language = $_POST['language'];
}
else{
$language = 1;
}
if($language == 1){
$answer =$data['extra_demo'][$a]->simplified_chinese_answer;
}
else if($language == 2){
$answer =$data['extra_demo'][$a]->traditional_chinese_answer;
}
else if($language == 3){
$answer = $data['extra_demo'][$a]->english_answer;
}
$thead = explode("_",$answer);
for($t = 0;$t < count($thead);$t++)
{
$this->excel->getActiveSheet()->setCellValue($letter.$k, $data['details'][$x][$i][$thead[$t]]);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle($letter.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$letter++;
}
}
}
}
}
}
$z = $z + 7;
}
}
错误在phpexcel中获取的行如下
$upperLeft = $aReferences[0];