PHPExcel生成的Excel错误-无法更新链接

PHPExcel生成的Excel错误-无法更新链接,php,phpexcel,Php,Phpexcel,我的PHPExcel生成的excel包含一个条形图和一个饼图,会自动发送到电子邮件。下载并打开电子邮件附件时(您必须单击“启用编辑”),它会显示此警报框: 在这之后,您可以在单元格中看到预期的数据,并看到图表的空白画布 我关闭excel文档并再次打开它,这次我将显示预期的图表以及此警报框覆盖的数据集: 单击第二个警报框中的更新链接将解析为启动第一个警报框。在中单击“继续”将解析为空白图表,仅显示带有axis的空白画布 我的代码使用大量变量来确定每个数据字段的单元格位置。我试着在脚本末尾使用E

我的PHPExcel生成的excel包含一个条形图和一个饼图,会自动发送到电子邮件。下载并打开电子邮件附件时(您必须单击“启用编辑”),它会显示此警报框:

在这之后,您可以在单元格中看到预期的数据,并看到图表的空白画布

我关闭excel文档并再次打开它,这次我将显示预期的图表以及此警报框覆盖的数据集:

单击第二个警报框中的更新链接将解析为启动第一个警报框。在中单击“继续”将解析为空白图表,仅显示带有axis的空白画布

我的代码使用大量变量来确定每个数据字段的单元格位置。我试着在脚本末尾使用EXIT,正如这里的一个答案所建议的那样。那没有;不行

代码示例:

// Add some data
        $objPHPExcel->setActiveSheetIndex(0)
        ->setCellValue('A'.$StartRow, 'Date')
        ->setCellValue('B'.$StartRow, $ndate)
        ->setCellValue('C'.$ParticipantStartLabel, 'Enrolled')
        ->setCellValue('D'.$ParticipantStartLabel, 'Logged In')
        ->setCellValue('E'.$ParticipantStartLabel, 'Yet to Log In')
        ->setCellValue('F'.$ParticipantStartLabel, 'Monitors (BOI, EDC and AMI)')
        ->setCellValue('B'.$ParticipantStartDetails, 'Participants on the program')
        ->setCellValue('C'.$ParticipantStartDetails, $ParticipantEnrolled)
        ->setCellValue('D'.$ParticipantStartDetails, $ParticipantLoggin)
        ->setCellValue('E'.$ParticipantStartDetails, $ParticipantYettoLog)
        ->setCellValue('F'.$ParticipantStartDetails, $Monitors) //$Monitors
        ->setCellValue('A'.$CoursesStartRow, 'S/N')
        ->setCellValue('B'.$CoursesStartRow, 'Course')
        ->setCellValue('C'.$CoursesStartRow, 'Enrolled')
        ->setCellValue('D'.$CoursesStartRow, 'Completed')
        ->setCellValue('E'.$CoursesStartRow, 'Incomplete');

        //print courses for single dataset
        for( $i = 0 ; $i < $NumCourses; $i++ ){ 
        $newi = $i + 1;
            $newCoursesStartRow = $CoursesStartRow + $newi;     

            $objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A'.$newCoursesStartRow, $newi)
            ->setCellValue('B'.$newCoursesStartRow, $Courses[$i])   // continue to Add some data on courses
            ->setCellValue('C'.$newCoursesStartRow, $CoursesEnrolled[$i])
            ->setCellValue('D'.$newCoursesStartRow, $CoursesCompleted[$i])
            ->setCellValue('E'.$newCoursesStartRow, $CoursesIncompleted[$i]);
        }
//添加一些数据
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.$StartRow,'Date')
->setCellValue('B'$StartRow,$ndate)
->setCellValue('C'.$ParticipantStartLabel,'Registered')
->setCellValue('D'.$ParticipantStartLabel,'Logged In')
->setCellValue('E'.$ParticipantStartLabel',尚未登录')
->setCellValue('F'.$ParticipantStartLabel',监视器(BOI、EDC和AMI)'
->setCellValue('B'.$ParticipantStartDetails,'项目参与者')
->setCellValue('C'.$ParticipantStartDetails,$participantRolled)
->setCellValue('D'.$ParticipantStartDetails,$ParticipantLoggin)
->setCellValue('E'.$ParticipantStartDetails,$participantETTOLOG)
->setCellValue('F'.$ParticipantStartDetails,$Monitors)/$Monitors
->setCellValue('A'.$CourseStartRow,'S/N')
->setCellValue('B'.$CourseStartRow,'Course')
->setCellValue('C'.$CourseStartRow,'Registered')
->setCellValue('D'$CourseStartRow,'Completed')
->setCellValue('E'.$CourseStartRow,'Completed');
//为单个数据集打印课程
对于($i=0;$i<$NumCourses;$i++){
$newi=$i+1;
$newCourseStartrow=$CourseStartrow+$newi;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.$newCourseStartRow,$newi)
->setCellValue('B'.$NewCourseStartRow,$Courses[$i])//继续添加有关课程的一些数据
->setCellValue('C'.$NewCourseStartRow,$CoursesEnrolled[$i])
->setCellValue('D'.$NewCourseStartRow,$CoursesCompleted[$i])
->setCellValue('E'.$NewCourseStartRow,$CoursesIncompleted[$i]);
}

感谢您提供帮助,解释为什么文档不会仅通过显示此分散注意力的警报框打开。

这称为安全性,Microsoft已将其应用于所有最新版本的MS Excel中。其目的是防止任何恶意excel文件执行任意代码。不幸的是,由于一些人选择使用Excel电子表格处理恶意软件,Microsoft选择提供这些警告,以表明他们无法保证此电子表格可能包含危险内容,并且打开该电子表格的用户必须有意识地决定接受风险


通常,只有当电子表格引用其他电子表格文件或试图访问远程数据时,才会出现此错误。您是否正在使用可能包含这些内容的模板构建文件?

谢谢您,先生。我真的希望您看到了这些图像(不知道如何在不点击标题的情况下显示),我理解启用编辑作为安全性(我们对word有相同的体验)。但启用编辑后,系统会要求您启用内容,然后您会看到上面的第一个警告框。我认为启用内容后,excel工作表应正常显示。我的场景:填充并提交一个HTML表单,PHP将输入绘制成变量,然后用变量填充单元格。单元格中的数据用于输出图表(条形图和饼图),我注释掉了行//$objPHPExcel->getActiveSheet()->addChart($chart);要删除图表,请在启用编辑后立即打开excel文档。因此,警报框是由图表生成过程中的某些因素引起的。我还尝试通过Excel5版本和xls扩展生成它,它正常打开,但没有任何图表的迹象。Excel5 Writer不支持任何图表,仅适用于Excel2007。。。。。但是如果问题出在你的图表上,那么你当然应该告诉我你如何创建图表的细节哦,好的。下面是整个代码的清单excelchart.php,对此没有响应