PHPexcel 为未设置的值生成 CSV(每行具有不同的列数)
PHPexcel generated CSV for values not set (each row with diff. no. of col's)
使用以下代码生成 CSV 文件
$objPHPExcel->setActiveSheetIndex( 0 )
->setCellValue( 'A1', 'one' )
->setCellValue( 'B1', 'two' )
->setCellValue( 'C1', 'three' );
$objPHPExcel->setActiveSheetIndex( 0 )
->setCellValue( 'A2', 'mon' )
->setCellValue( 'B2', 'tue' )
->setCellValue( 'C2', 'wed' )
->setCellValue( 'D2', 'thu' )
->setCellValue( 'E2', 'fri' );
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setUseBOM(TRUE)
->setDelimiter(',')
->setEnclosure('')
->setSheetIndex(0)
->save('php://output');
所以上面的代码生成了结果。但我不想为 D1 & E1 单元格生成逗号。
Would like to get result as :
one,two,three
mon,tue,wed,thu,fri
有没有办法定义 PHPExcel 读取每一行?
终于写了我自己的 class github
使用以下代码生成 CSV 文件
$objPHPExcel->setActiveSheetIndex( 0 )
->setCellValue( 'A1', 'one' )
->setCellValue( 'B1', 'two' )
->setCellValue( 'C1', 'three' );
$objPHPExcel->setActiveSheetIndex( 0 )
->setCellValue( 'A2', 'mon' )
->setCellValue( 'B2', 'tue' )
->setCellValue( 'C2', 'wed' )
->setCellValue( 'D2', 'thu' )
->setCellValue( 'E2', 'fri' );
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setUseBOM(TRUE)
->setDelimiter(',')
->setEnclosure('')
->setSheetIndex(0)
->save('php://output');
所以上面的代码生成了结果。但我不想为 D1 & E1 单元格生成逗号。
Would like to get result as :
one,two,three
mon,tue,wed,thu,fri
有没有办法定义 PHPExcel 读取每一行?
终于写了我自己的 class github