PHPExcel不能在php函数中的foreach cammand中写超过117列

时间:2018-09-28 08:40:37

标签: php foreach phpexcel

我是PHPExcel的新手 我有一个有关在PHP CI框架中导出Excel文件的项目。 现在我的代码有问题

function download($query_id = 0, $offset = 0){
    $object = new PHPExcel();
    $object->setActiveSheetIndex(0);
    $participant = $this->karyasiswa_model->search_karyasiswa(false,$offset);
    $participant = $participant['rows'];
    $excel_row = 5;
    $nomor = 1;
    foreach ($participant as $row) {
        $sisa = $row->jumlah-$row->smt_1-$row->smt_2-$row->smt_3-$row->smt_5-$row->smt_6-$row->smt_7-$row->smt_8;
        $object->getActiveSheet()->setCellValueByColumnAndRow(0,$excel_row,$nomor);
        $object->getActiveSheet()->setCellValueByColumnAndRow(1,$excel_row,$row->nama_mahasiswa); // fetched -> instead of ['']
        $object->getActiveSheet()->setCellValueByColumnAndRow(2,$excel_row,$row->tahun_terima);
        $object->getActiveSheet()->setCellValueByColumnAndRow(3,$excel_row,$row->semester);
        $object->getActiveSheet()->setCellValueByColumnAndRow(4,$excel_row,$row->status);
        $object->getActiveSheet()->setCellValueByColumnAndRow(5,$excel_row,$row->jenis_beasiswa);
        $object->getActiveSheet()->setCellValueByColumnAndRow(6,$excel_row,$row->prodi);
        $object->getActiveSheet()->setCellValueByColumnAndRow(7,$excel_row,'');
        $object->getActiveSheet()->setCellValueByColumnAndRow(8,$excel_row,'');
        $object->getActiveSheet()->setCellValueByColumnAndRow(9,$excel_row,$row->jumlah);
        $object->getActiveSheet()->setCellValueByColumnAndRow(10,$excel_row,$row->smt_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(11,$excel_row,$row->uang_1_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(12,$excel_row,$row->uang_1_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(13,$excel_row,$row->uang_1_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(14,$excel_row,$row->uang_1_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(15,$excel_row,$row->uang_1_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(16,$excel_row,$row->uang_1_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(17,$excel_row,$row->uang_1_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(18,$excel_row,$row->smt_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(19,$excel_row,$row->uang_2_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(20,$excel_row,$row->uang_2_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(21,$excel_row,$row->uang_2_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(22,$excel_row,$row->uang_2_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(23,$excel_row,$row->uang_2_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(24,$excel_row,$row->uang_2_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(25,$excel_row,$row->uang_2_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(26,$excel_row,$row->smt_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(27,$excel_row,$row->uang_3_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(28,$excel_row,$row->uang_3_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(29,$excel_row,$row->uang_3_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(30,$excel_row,$row->uang_3_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(31,$excel_row,$row->uang_3_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(32,$excel_row,$row->uang_3_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(33,$excel_row,$row->uang_3_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(34,$excel_row,$row->smt_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(35,$excel_row,$row->uang_4_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(36,$excel_row,$row->uang_4_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(37,$excel_row,$row->uang_4_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(38,$excel_row,$row->uang_4_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(39,$excel_row,$row->uang_4_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(40,$excel_row,$row->uang_4_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(41,$excel_row,$row->uang_4_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(42,$excel_row,$row->smt_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(43,$excel_row,$row->uang_5_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(44,$excel_row,$row->uang_5_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(45,$excel_row,$row->uang_5_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(46,$excel_row,$row->uang_5_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(47,$excel_row,$row->uang_5_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(48,$excel_row,$row->uang_5_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(49,$excel_row,$row->uang_5_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(50,$excel_row,$row->smt_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(51,$excel_row,$row->uang_6_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(52,$excel_row,$row->uang_6_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(53,$excel_row,$row->uang_6_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(54,$excel_row,$row->uang_6_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(55,$excel_row,$row->uang_6_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(56,$excel_row,$row->uang_6_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(57,$excel_row,$row->uang_6_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(58,$excel_row,$row->smt_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(59,$excel_row,$row->uang_7_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(50,$excel_row,$row->uang_7_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(61,$excel_row,$row->uang_7_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(62,$excel_row,$row->uang_7_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(63,$excel_row,$row->uang_7_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(64,$excel_row,$row->uang_7_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(65,$excel_row,$row->uang_7_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(66,$excel_row,$row->smt_8);
        $object->getActiveSheet()->setCellValueByColumnAndRow(67,$excel_row,$row->uang_8_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(68,$excel_row,$row->uang_8_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(69,$excel_row,$row->uang_8_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(70,$excel_row,$row->uang_8_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(71,$excel_row,$row->uang_8_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(72,$excel_row,$row->uang_8_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(73,$excel_row,$row->uang_8_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(74,$excel_row,$row->smt_9);
        $object->getActiveSheet()->setCellValueByColumnAndRow(75,$excel_row,$row->uang_9_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(76,$excel_row,$row->uang_9_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(77,$excel_row,$row->uang_9_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(78,$excel_row,$row->uang_9_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(79,$excel_row,$row->uang_9_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(80,$excel_row,$row->uang_9_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(81,$excel_row,$row->uang_9_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(82,$excel_row,$row->smt_10);
        $object->getActiveSheet()->setCellValueByColumnAndRow(83,$excel_row,$row->uang_10_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(84,$excel_row,$row->uang_10_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(85,$excel_row,$row->uang_10_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(86,$excel_row,$row->uang_10_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(87,$excel_row,$row->uang_10_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(88,$excel_row,$row->uang_10_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(89,$excel_row,$row->uang_10_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(90,$excel_row,$row->smt_11);
        $object->getActiveSheet()->setCellValueByColumnAndRow(91,$excel_row,$row->uang_11_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(92,$excel_row,$row->uang_11_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(93,$excel_row,$row->uang_11_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(94,$excel_row,$row->uang_11_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(95,$excel_row,$row->uang_11_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(96,$excel_row,$row->uang_11_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(97,$excel_row,$row->uang_11_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(98,$excel_row,$row->smt_12);
        $object->getActiveSheet()->setCellValueByColumnAndRow(99,$excel_row,$row->uang_12_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(100,$excel_row,$row->uang_12_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(101,$excel_row,$row->uang_12_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(102,$excel_row,$row->uang_12_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(103,$excel_row,$row->uang_12_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(104,$excel_row,$row->uang_12_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(105,$excel_row,$row->uang_12_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(106,$excel_row,$row->smt_13);
        $object->getActiveSheet()->setCellValueByColumnAndRow(107,$excel_row,$row->uang_13_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(108,$excel_row,$row->uang_13_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(109,$excel_row,$row->uang_13_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(110,$excel_row,$row->uang_13_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(111,$excel_row,$row->uang_13_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(112,$excel_row,$row->uang_13_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(113,$excel_row,$row->uang_13_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(114,$excel_row,$row->smt_14);
        $object->getActiveSheet()->setCellValueByColumnAndRow(115,$excel_row,$row->uang_14_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(116,$excel_row,$row->uang_14_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(117,$excel_row,$row->uang_14_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(118,$excel_row,$row->uang_14_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(119,$excel_row,$row->uang_14_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(120,$excel_row,$row->uang_14_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(121,$excel_row,$row->uang_14_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(122,$excel_row,$sisa);
        $excel_row++;
        $nomor++;
    }

    $object_writer = PHPExcel_IOFactory::createWriter($object,'Excel2007');
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment; filename=data'.xlsx');
    $object_writer->save('php://output');
}

有123个$ objects命令要在Excel工作表中编写。我试图将这些行导出到excel,但是下载文件后,它告诉我文件格式或文件扩展名无效(文件excel错误)。

我要问的是foreach中有多少命令行,尤其是可以实现的功能? excel写函数不能在foreach行中执行超过117个命令,这是真的吗?

然后我尝试了这段代码(我在此foreach中删除了16行命令)

function download($query_id = 0, $offset = 0){
    $object = new PHPExcel();
    $object->setActiveSheetIndex(0);
    $participant = $this->karyasiswa_model->search_karyasiswa($query_array,$offset);
    $participant = $participant['rows'];
    $excel_row = 5;
    $nomor = 1;
    foreach ($participant as $row) {
        $sisa = $row->jumlah-$row->smt_1-$row->smt_2-$row->smt_3-$row->smt_5-$row->smt_6-$row->smt_7-$row->smt_8;
        $object->getActiveSheet()->setCellValueByColumnAndRow(0,$excel_row,$nomor);
        $object->getActiveSheet()->setCellValueByColumnAndRow(1,$excel_row,$row->nama_mahasiswa); // fetched -> instead of ['']
        $object->getActiveSheet()->setCellValueByColumnAndRow(2,$excel_row,$row->tahun_terima);
        $object->getActiveSheet()->setCellValueByColumnAndRow(3,$excel_row,$row->semester);
        $object->getActiveSheet()->setCellValueByColumnAndRow(4,$excel_row,$row->status);
        $object->getActiveSheet()->setCellValueByColumnAndRow(5,$excel_row,$row->jenis_beasiswa);
        $object->getActiveSheet()->setCellValueByColumnAndRow(6,$excel_row,$row->prodi);
        $object->getActiveSheet()->setCellValueByColumnAndRow(7,$excel_row,'');
        $object->getActiveSheet()->setCellValueByColumnAndRow(8,$excel_row,'');
        $object->getActiveSheet()->setCellValueByColumnAndRow(9,$excel_row,$row->jumlah);
        $object->getActiveSheet()->setCellValueByColumnAndRow(10,$excel_row,$row->smt_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(11,$excel_row,$row->uang_1_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(12,$excel_row,$row->uang_1_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(13,$excel_row,$row->uang_1_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(14,$excel_row,$row->uang_1_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(15,$excel_row,$row->uang_1_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(16,$excel_row,$row->uang_1_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(17,$excel_row,$row->uang_1_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(18,$excel_row,$row->smt_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(19,$excel_row,$row->uang_2_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(20,$excel_row,$row->uang_2_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(21,$excel_row,$row->uang_2_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(22,$excel_row,$row->uang_2_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(23,$excel_row,$row->uang_2_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(24,$excel_row,$row->uang_2_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(25,$excel_row,$row->uang_2_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(26,$excel_row,$row->smt_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(27,$excel_row,$row->uang_3_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(28,$excel_row,$row->uang_3_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(29,$excel_row,$row->uang_3_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(30,$excel_row,$row->uang_3_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(31,$excel_row,$row->uang_3_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(32,$excel_row,$row->uang_3_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(33,$excel_row,$row->uang_3_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(34,$excel_row,$row->smt_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(35,$excel_row,$row->uang_4_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(36,$excel_row,$row->uang_4_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(37,$excel_row,$row->uang_4_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(38,$excel_row,$row->uang_4_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(39,$excel_row,$row->uang_4_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(40,$excel_row,$row->uang_4_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(41,$excel_row,$row->uang_4_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(42,$excel_row,$row->smt_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(43,$excel_row,$row->uang_5_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(44,$excel_row,$row->uang_5_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(45,$excel_row,$row->uang_5_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(46,$excel_row,$row->uang_5_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(47,$excel_row,$row->uang_5_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(48,$excel_row,$row->uang_5_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(49,$excel_row,$row->uang_5_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(50,$excel_row,$row->smt_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(51,$excel_row,$row->uang_6_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(52,$excel_row,$row->uang_6_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(53,$excel_row,$row->uang_6_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(54,$excel_row,$row->uang_6_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(55,$excel_row,$row->uang_6_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(56,$excel_row,$row->uang_6_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(57,$excel_row,$row->uang_6_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(58,$excel_row,$row->smt_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(59,$excel_row,$row->uang_7_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(50,$excel_row,$row->uang_7_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(61,$excel_row,$row->uang_7_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(62,$excel_row,$row->uang_7_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(63,$excel_row,$row->uang_7_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(64,$excel_row,$row->uang_7_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(65,$excel_row,$row->uang_7_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(66,$excel_row,$row->smt_8);
        $object->getActiveSheet()->setCellValueByColumnAndRow(67,$excel_row,$row->uang_8_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(68,$excel_row,$row->uang_8_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(69,$excel_row,$row->uang_8_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(70,$excel_row,$row->uang_8_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(71,$excel_row,$row->uang_8_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(72,$excel_row,$row->uang_8_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(73,$excel_row,$row->uang_8_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(74,$excel_row,$row->smt_9);
        $object->getActiveSheet()->setCellValueByColumnAndRow(75,$excel_row,$row->uang_9_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(76,$excel_row,$row->uang_9_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(77,$excel_row,$row->uang_9_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(78,$excel_row,$row->uang_9_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(79,$excel_row,$row->uang_9_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(80,$excel_row,$row->uang_9_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(81,$excel_row,$row->uang_9_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(82,$excel_row,$row->smt_10);
        $object->getActiveSheet()->setCellValueByColumnAndRow(83,$excel_row,$row->uang_10_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(84,$excel_row,$row->uang_10_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(85,$excel_row,$row->uang_10_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(86,$excel_row,$row->uang_10_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(87,$excel_row,$row->uang_10_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(88,$excel_row,$row->uang_10_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(89,$excel_row,$row->uang_10_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(90,$excel_row,$row->smt_11);
        $object->getActiveSheet()->setCellValueByColumnAndRow(91,$excel_row,$row->uang_11_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(92,$excel_row,$row->uang_11_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(93,$excel_row,$row->uang_11_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(94,$excel_row,$row->uang_11_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(95,$excel_row,$row->uang_11_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(96,$excel_row,$row->uang_11_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(97,$excel_row,$row->uang_11_7);
        //
        // object 12 to 13 deleted
        //
        $object->getActiveSheet()->setCellValueByColumnAndRow(114,$excel_row,$row->smt_14);
        $object->getActiveSheet()->setCellValueByColumnAndRow(115,$excel_row,$row->uang_14_1);
        $object->getActiveSheet()->setCellValueByColumnAndRow(116,$excel_row,$row->uang_14_2);
        $object->getActiveSheet()->setCellValueByColumnAndRow(117,$excel_row,$row->uang_14_3);
        $object->getActiveSheet()->setCellValueByColumnAndRow(118,$excel_row,$row->uang_14_4);
        $object->getActiveSheet()->setCellValueByColumnAndRow(119,$excel_row,$row->uang_14_5);
        $object->getActiveSheet()->setCellValueByColumnAndRow(120,$excel_row,$row->uang_14_6);
        $object->getActiveSheet()->setCellValueByColumnAndRow(121,$excel_row,$row->uang_14_7);
        $object->getActiveSheet()->setCellValueByColumnAndRow(122,$excel_row,$sisa);
        $excel_row++;
        $nomor++;
    }

    $object_writer = PHPExcel_IOFactory::createWriter($object,'Excel2007');
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment; filename=data.xlsx');
    $object_writer->save('php://output');
}

删除16个$ objects命令(其余大约是106个$ object命令)后,我下载的文件可以正常打开,完全没有错误。

所以我认为PHPExcel中存在一个错误,但是如果我错了,我的代码将是错误的。 感谢您的关注。请使用此代码给我解决方案

0 个答案:

没有答案