本文整理汇总了PHP中PSU::indexToExcelAlpha方法的典型用法代码示例。如果您正苦于以下问题:PHP PSU::indexToExcelAlpha方法的具体用法?PHP PSU::indexToExcelAlpha怎么用?PHP PSU::indexToExcelAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSU
的用法示例。
在下文中一共展示了PSU::indexToExcelAlpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xlsx
/**
* renders an xlsx version of the report
*/
public function xlsx($data, $meta = array())
{
require_once 'phpexcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// Set properties
$default_meta = array('creator' => 'PSU Tools', 'last_modified_by' => 'PSU Tools', 'title' => 'XLSX Export', 'subject' => 'Plymouth State University', 'description' => 'Generated using PSU Tools', 'keywords' => 'office 2007 openxml php', 'company' => 'Plymouth State University', 'category' => 'Plymouth State University', 'file_name' => 'export', 'output' => 'php://output');
$meta = array_merge($default_meta, $meta);
$objPHPExcel->setActiveSheetIndex(0);
// generate headings
$i = 1;
if (count($meta['headings']) > 0) {
$col = 0;
$letter = 'A';
foreach ($meta['headings'] as $v) {
$letter = PSU::indexToExcelAlpha($col);
$objPHPExcel->getActiveSheet()->setCellValue($letter . $i, $v);
$objPHPExcel->getActiveSheet()->getStyle($letter . $i)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getColumnDimension($letter)->setAutoSize(true);
$col++;
}
// end foreach
$objPHPExcel->getActiveSheet()->getStyle('A1:' . $letter . '1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A1:' . $letter . '1')->getFill()->getStartColor()->setARGB('FFdddddd');
$i++;
}
// now for the actual data
foreach ($data as $row) {
$col = 0;
foreach ($row as $key => $value) {
$letter = PSU::indexToExcelAlpha($col);
if (is_array($meta['types'])) {
switch ($meta['types'][$key]) {
case 'boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
break;
case 'formula':
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
break;
case 'inline':
$type = PHPExcel_Cell_DataType::TYPE_INLINE;
break;
case 'null':
$type = PHPExcel_Cell_DataType::TYPE_NULL;
break;
case 'number':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
break;
case 'string':
$type = PHPExcel_Cell_DataType::TYPE_STRING;
break;
default:
$type = 'AUTOMATIC';
}
if ($type == 'AUTOMATIC') {
$objPHPExcel->getActiveSheet()->setCellValue($letter . $i, $value);
} else {
$objPHPExcel->getActiveSheet()->getCell($letter . $i)->setValueExplicit($value, $type);
}
}
$col++;
}
//end foreach
$i++;
}
// end foreach
$objPHPExcel->getProperties()->setCreator($meta['creator'])->setLastModifiedBy($meta['last_modified_by'])->setTitle($meta['title'])->setSubject($meta['subject'])->setDescription($meta['description'])->setKeywords($meta['keywords'])->setCompany($meta['company'])->setCategory($meta['category']);
if (class_exists('ZipArchive')) {
$file_extension = 'xlsx';
$file_type = 'Excel2007';
} else {
$file_extension = 'xls';
$file_type = 'Excel5';
}
if ($meta['output'] == 'php://output') {
// Redirect output to a client
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $meta['file_name'] . '.' . $file_extension . '"');
self::downloadfix();
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $file_type);
$objWriter->save($meta['output']);
}