let me explain more . i have to attach an excel file {which contains 4 numbers that are a test result and draw a chart } I've done the test i have the result, i have done sending with attachment but i can't make the file .require_once '../Classes/PHPExcel.php';$fileType = 'Excel2007';$fileName = 'Result.xlsx';// Read the file$objReader = PHPExcel_IOFactory::createReader($fileType);$objPHPExcel = $objReader->load($fileName);// Change the file$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);$objSheet = $objPHPExcel->setActiveSheetIndex(0); objSheet->getCell('A2')->setValue($SumY ); objSheet->getCell('B2')->setValue($SumR ); objSheet->getCell('C2')->setValue($SumB ); objSheet->getCell('D2')->setValue($SumG );// Write the file$objWriter->save('Result.xlsx');推荐答案告诉PHPExcel您想要在读写时包括图表Tell PHPExcel that you want to include charts when reading and writing假设图表是在模板中定义的Assuming that the chart is defined in your templaterequire_once '../Classes/PHPExcel.php';$fileType = 'Excel2007';$fileName = 'Result.xlsx';// Read the file (including chart template)$objReader = PHPExcel_IOFactory::createReader($fileType);$objReader->setIncludeCharts(TRUE);$objPHPExcel = $objReader->load($fileName);// Change the file$objSheet = $objPHPExcel->setActiveSheetIndex(0);$objSheet->getCell('A2')->setValue($SumY );$objSheet->getCell('B2')->setValue($SumR );$objSheet->getCell('C2')->setValue($SumB );$objSheet->getCell('D2')->setValue($SumG );// Write the file (including chart)$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);$objWriter->setIncludeCharts(TRUE);$objWriter->save('Result.xlsx');如果未在模板中定义图表,则需要在代码中创建If the chart isn't defined in your template, then you need to create it in your code 这篇关于无法读取和写入XLSX文件的PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-03 18:41