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

时间:2017-03-19 21:50:20

标签: php phpexcel

我的PHPExcel生成的Excel包含条形图和饼图,并自动触发到电子邮件。下载并打开电子邮件附件(您必须单击启用编辑)后,它将显示此警告框:

When the email attachment is downloaded and opened (you have to click enable editing) it displays this alert box:

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

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

I close the excel document and open it again, this time I get the expected chart displayed along with data sets overlayed by this alert box:

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

我的代码使用大量变量来确定每个数据字段的单元格位置。我尝试在脚本的末尾使用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]);
        }

任何帮助解释为什么文档不会随着显示这个分散注意力的警报框而打开的行为表示赞赏。

1 个答案:

答案 0 :(得分:0)

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

通常,如果电子表格引用其他电子表格文件,或者它尝试访问远程数据,则只会出现此错误。您是否正在构建可能包含这些文件的模板?