<?php
include_once('./Classes/PHPExcel.php');
$objPHPExcel = new PHPExcel();
$objSheet = $objPHPExcel->getActiveSheet();
$objSheet->setTitle('demo');
$data = array(
array('姓名','分数'),
array('李四','60'),
array('王五','70')
);
$column = 1;
foreach($data as $k => $v)
{
$span = ord("A");
foreach($v as $vk=>$vv)
{
$j = chr($span);
$objSheet->setCellValue($j.$column, $vv);
$span++;
}
$column++;
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel5');
$dir = dirname(__FILE__);
$objWriter->save($dir.'/demo.xlsx');
网友评论