0
我正在使用PHPExcel來生成列表。溢出寬度phpexcel
的問題是,文本溢出小區B
如何把一個固定的寬度和長度自動的寬度,這樣它不會溢出?
附件:
代碼:
$objPHPExcel = new PHPExcel();
$objPHPExcel->
getProperties()
->setCreator("TEDnologia.com")
->setLastModifiedBy("TEDnologia.com")
->setTitle("Exportar Excel con PHP")
->setSubject("Documento de prueba")
->setDescription("Documento generado con PHPExcel")
->setKeywords("usuarios phpexcel")
->setCategory("reportes");
$query = mysql_query('select * from articulos');
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Nombre')
->setCellValue('B1', 'E-mail')
->setCellValue('C1', 'E-mail')
;
$i=2;
while($row = mysql_fetch_assoc($query)){
$xx = "A".$i;
$xxx = "B".$i;
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($xx, $row["cod"])
->setCellValue($xxx, $row["descripcion"]);
;
$xxxx = "C".$i;
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('archivos/articulos/'.$row["imagen"].'');
$objDrawing->setCoordinates($xxxx);
$objDrawing->setHeight(36);
$objDrawing->setWidth(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$i++;
}
$objPHPExcel->getActiveSheet()->setTitle('Usuarios');
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
想想你會怎麼做它在MS Excel本身,然後再尋找在PHPExcel等效方法 – 2014-09-24 18:20:08
HTTP:/ /www.excelforum.com/excel-general/634377-prevent-cell-overflow.html – 2014-09-25 22:48:07