美文网首页
php-write-excel

php-write-excel

作者: robertzhai | 来源:发表于2022-12-11 18:35 被阅读0次
<?php
ini_set('memory_limit',-1); //没有内存限制

require_once dirname(__FILE__) . '/PHPExcel-1.8/Classes/PHPExcel.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
$row = 1;

foreach ($excel_data as $data) {
    $objPHPExcel->setActiveSheetIndex(0)
        ->setCellValue('A' . $row, $cat_id)
        ->setCellValue('B' . $row, $content_id)
        ->setCellValue('C' . $row, '')
        ->setCellValue('D' . $row, '')
        ->setCellValue('E' . $row, '');
    $row++;
}
                


$objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s'), " Write to Excel2007 format", EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', time() . '.xlsx', __FILE__));

相关文章

网友评论

      本文标题:php-write-excel

      本文链接:https://www.haomeiwen.com/subject/wwnfqdtx.html