Using PHPEXCEL to export a MYSQL table to EXCEL, the first row of the table is always missing
Ray
Ray 2019-06-13 13:11:07
0
0
1185

As mentioned, have any friends encountered similar problems?

// Instantiate a new PHPExcel object $objPHPExcel = new PHPExcel(); // Set the active Excel worksheet to sheet 0 $objPHPExcel->setActiveSheetIndex(0); // Initialise the Excel row number $objPHPExcel->getActiveSheet()->setCellValue("A1","下单日"); $objPHPExcel->getActiveSheet()->setCellValue("B1","销售区域"); $objPHPExcel->getActiveSheet()->setCellValue("C1","销售组"); $objPHPExcel->getActiveSheet()->setCellValue("D1","销售姓名"); $objPHPExcel->getActiveSheet()->setCellValue("E1","项目号"); $objPHPExcel->getActiveSheet()->setCellValue("F1","客户"); $objPHPExcel->getActiveSheet()->setCellValue("G1","订单号"); $objPHPExcel->getActiveSheet()->setCellValue("H1","订单行次"); $objPHPExcel->getActiveSheet()->setCellValue("I1","物料号"); $objPHPExcel->getActiveSheet()->setCellValue("J1","物料描述(英文)"); $objPHPExcel->getActiveSheet()->setCellValue("K1","销售单位"); $objPHPExcel->getActiveSheet()->setCellValue("L1","订单总数量"); $objPHPExcel->getActiveSheet()->setCellValue("M1","未发货数量"); $objPHPExcel->getActiveSheet()->setCellValue("N1","已发货数量"); $objPHPExcel->getActiveSheet()->setCellValue("O1","确认库存数量"); $objPHPExcel->getActiveSheet()->setCellValue("P1","要求出库日"); $objPHPExcel->getActiveSheet()->setCellValue("Q1","预计出库日"); $objPHPExcel->getActiveSheet()->setCellValue("R1","发货仓库"); $objPHPExcel->getActiveSheet()->setCellValue("S1","发货冻结"); $objPHPExcel->getActiveSheet()->setCellValue("T1","发货冻结"); $objPHPExcel->getActiveSheet()->setCellValue("U1","发货单号"); $objPHPExcel->getActiveSheet()->setCellValue("V1","运输条件"); $objPHPExcel->getActiveSheet()->setCellValue("W1","订单状态"); $row11Count = 2; // Iterate through each result from the SQL query in turn // We fetch each database result row into $row in turn while($row11 = mysqli_fetch_array($result11)){ // Set cell An to the "name" column from the database (assuming you have a column called name) // where n is the Excel row number (ie cell A1 in the first row) $objPHPExcel->getActiveSheet()->SetCellValue('A'.$row11Count, $row11['Created on 下单日']); // Set cell Bn to the "age" column from the database (assuming you have a column called age) // where n is the Excel row number (ie cell A1 in the first row) $objPHPExcel->getActiveSheet()->SetCellValue('B'.$row11Count, $row11['SalesOffice']); $objPHPExcel->getActiveSheet()->SetCellValue('C'.$row11Count, $row11['SalesGroup']); $objPHPExcel->getActiveSheet()->SetCellValue('D'.$row11Count, $row11['Sales group descript 销售姓名']); $objPHPExcel->getActiveSheet()->SetCellValue('E'.$row11Count, $row11['WBS']); $objPHPExcel->getActiveSheet()->SetCellValue('F'.$row11Count, $row11['Customer name 客户名']); $objPHPExcel->getActiveSheet()->SetCellValue('G'.$row11Count, $row11['Order No. 订单号']); $objPHPExcel->getActiveSheet()->SetCellValue('H'.$row11Count, $row11['Line 订单序号']); $objPHPExcel->getActiveSheet()->SetCellValue('I'.$row11Count, $row11['Material 物料号']); $objPHPExcel->getActiveSheet()->SetCellValue('J'.$row11Count, $row11['Item Description 物料描述']); $objPHPExcel->getActiveSheet()->SetCellValue('K'.$row11Count, $row11['Unt 销售单位']); $objPHPExcel->getActiveSheet()->SetCellValue('L'.$row11Count, $row11['Ordered Qty 订单数量']); $objPHPExcel->getActiveSheet()->SetCellValue('M'.$row11Count, $row11['Opn.Qty.Dlv 未发数量']); $objPHPExcel->getActiveSheet()->SetCellValue('N'.$row11Count, $row11['Deliv. Qty. 已发数量']); $objPHPExcel->getActiveSheet()->SetCellValue('O'.$row11Count, $row11['Conf Stock Qty 确认库存数量']); $objPHPExcel->getActiveSheet()->SetCellValue('P'.$row11Count, $row11['Req.Date 要求出库日']); $objPHPExcel->getActiveSheet()->SetCellValue('Q'.$row11Count, $row11['Conf.dat(ETD) IL 预计出库日']); $objPHPExcel->getActiveSheet()->SetCellValue('R'.$row11Count, $row11['SupPlnt 发货仓库']); $objPHPExcel->getActiveSheet()->SetCellValue('S'.$row11Count, $row11['Delivery Block 发货冻结']); $objPHPExcel->getActiveSheet()->SetCellValue('T'.$row11Count, $row11['Dlv No 发货单号']); $objPHPExcel->getActiveSheet()->SetCellValue('U'.$row11Count, $row11['Shipping condition']); $objPHPExcel->getActiveSheet()->SetCellValue('V'.$row11Count, $row11['Shipping point']); $objPHPExcel->getActiveSheet()->SetCellValue('W'.$row11Count, $row11['Order status 订单状态']); // Increment the Excel row counter $row11Count++; } // Instantiate a Writer to create an OfficeOpenXML Excel .xlsx file $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); // Write the Excel file to filename some_excel_file.xlsx in the current directory $objWriter->save('OP.xlsx'); echo "另存为Excel"; mysqli_close($link); //关闭连接


Ray
Ray

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!