如何在phpexcel中設置第一行,當我使用phpexcel導出文件時,我真的對這個東西是新的,結果總是以A1行開始!如何跳過它..? 我想開始插入我的數據在其他行像A4或任何其他行。 這是我在我的代碼(更新完整的代碼)如何在phpexcel中設置第一行
function theme_views_data_export_xlsx_body(&$vars) {
_views_data_export_header_shared_preprocess($vars);
_views_data_export_body_shared_preprocess($vars);
$complete_array = array_merge(array($vars['header']), $vars['themed_rows']);
// Decode HTML entities.
foreach ($complete_array as &$row) {
foreach ($row as &$value) {
$value = decode_entities($value);
}
}
// Load PHPExcel library.
$library = libraries_load('PHPExcel');
// Create PHPExcel spreadsheet and add rows to it.
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('F1', '=E2');
$objPHPExcel->getActiveSheet()->fromArray($complete_array);
$objPHPExcel->getActiveSheet()->setTitle('Nilai Ukk');
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
// $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()-
>setWrapText(true);
$excel_type = 'excel2007';
switch ($excel_type) {
default:
case 'excel2007':
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
break;
}
// Catch the output of the spreadsheet.
ob_start();
$objWriter->save('php://output');
$excelOutput = ob_get_clean();
return $excelOutput;
}
感謝
您是否嘗試過設置' - > setCellValue('A4','您的數據')等? – JustBaron
是的,但沒有運氣..! –