Open myloveGy opened 5 years ago
When I used PHP Excel to write a large numeric string, I found that the behaviors of 1.8.1 and 1.8.2 were inconsistent. My code is as follows:
$objPHPExcel = new \PHPExcel(); // Set document properties $objPHPExcel->getProperties() ->setCreator("REPORTINFO") ->setLastModifiedBy("VeryStar") ->setTitle("VeryStar REPORTINFO") ->setSubject("VeryStar REPORTINFO") ->setDescription("VeryStar REPORTINFO") ->setKeywords("VeryStar") ->setCategory("VeryStar"); $sheet_num = 1; $phpExcelActiveSheet = $objPHPExcel->getActiveSheet(); $objPHPExcel->setActiveSheetIndex(0)->setTitle('demo'); $objPHPExcel->getActiveSheet()->getStyle('E')->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_NUMBER); $objPHPExcel->getActiveSheet()->getStyle('G')->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_NUMBER); $phpExcelActiveSheet->setCellValue('A' . $sheet_num, 'PHP Version'); $phpExcelActiveSheet->setCellValue('B' . $sheet_num, 'System'); $phpExcelActiveSheet->setCellValue('C' . $sheet_num, 'Excel Version'); $phpExcelActiveSheet->setCellValue('D' . $sheet_num, 'test value 1'); $phpExcelActiveSheet->setCellValue('E' . $sheet_num, 'test value 2'); $phpExcelActiveSheet->setCellValue('F' . $sheet_num, 'test value 3'); $phpExcelActiveSheet->setCellValue('G' . $sheet_num, 'test value 4'); $sheet_num++; $phpExcelActiveSheet->setCellValue('A' . $sheet_num, PHP_VERSION); $phpExcelActiveSheet->setCellValue('B' . $sheet_num, PHP_OS); $phpExcelActiveSheet->setCellValue('C' . $sheet_num, '1.8.2'); $phpExcelActiveSheet->setCellValue('D' . $sheet_num, '898350553311499'."\t"); $phpExcelActiveSheet->setCellValue('E' . $sheet_num, '898350553311499'); $phpExcelActiveSheet->setCellValue('F' . $sheet_num, '898350553311491'."\t"); $phpExcelActiveSheet->setCellValue('G' . $sheet_num, '898350553311491'); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $file_name = '/data/demo-1.8.2.xlsx'; $objWriter->save($file_name);
1.8.2 Write is the following data: demo-1.8.2.xlsx
The number is found to be rounded up according to the mantissa But 1.8.1 does not have this problem: demo-1.8.1.xlsx
Actual Behaviour
When I used PHP Excel to write a large numeric string, I found that the behaviors of 1.8.1 and 1.8.2 were inconsistent. My code is as follows:
1.8.2 Write is the following data: demo-1.8.2.xlsx![1 8 2](https://user-images.githubusercontent.com/11523869/49499370-cc43f500-f8a8-11e8-9bb0-34b958910d1b.png)
The number is found to be rounded up according to the mantissa But 1.8.1 does not have this problem: demo-1.8.1.xlsx![1 8 1](https://user-images.githubusercontent.com/11523869/49499397-e41b7900-f8a8-11e8-98f1-ffa5a2d8819d.png)