0
我必須爲用戶在xls文件中在我的網站中執行的每個訂單添加(追加)一行。其實我想PHPexcel是最好的解決方案。 從A到K的每一列都預留作爲送貨地址。從L到O的列被保留(空白)。 在那些列之後,我必須添加一列,並且每個產品用戶的ID都是有序的。我怎麼能不知道每一列字母呢?有沒有辦法爲每個項目增加它?這是我的實際代碼:使用PHPexcel查找順序列
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load("ordini.xlsx");
$objPHPExcel->setActiveSheetIndex(0);
$row = $objPHPExcel->getActiveSheet()->getHighestRow()+1;
//echo $row;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $orderid);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $orderid);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $array['nome']);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, $array['cognome']);
$objPHPExcel->getActiveSheet()->SetCellValue('E'.$row, $array['cellulare']);
$objPHPExcel->getActiveSheet()->SetCellValue('F'.$row, $shippingmethod);
$objPHPExcel->getActiveSheet()->SetCellValue('G'.$row, "IT");
$objPHPExcel->getActiveSheet()->SetCellValue('H'.$row, $array['provincia']);
$objPHPExcel->getActiveSheet()->SetCellValue('I'.$row, $array['citta']);
$objPHPExcel->getActiveSheet()->SetCellValue('J'.$row, $array['indirizzo']." ".$array['civico']);
$objPHPExcel->getActiveSheet()->SetCellValue('K'.$row, $array['indirizzo']." ".$array['civico']);
$objPHPExcel->getActiveSheet()->SetCellValue('L'.$row, "");
$objPHPExcel->getActiveSheet()->SetCellValue('M'.$row, "");
$objPHPExcel->getActiveSheet()->SetCellValue('N'.$row, "");
$objPHPExcel->getActiveSheet()->SetCellValue('O'.$row, "");
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('ordini.xlsx');
?>
參見[第獲取e來自PHPExcel行和列索引的列的名稱](http://stackoverflow.com/questions/5536964/getting-the-name-of-a-column-from-the-row-and-column-indexes -in-phpexcel)。 – DCoder