php - PHPExcel multiple foreach loops -
I want to display all the rows from a table with the column names mentioned above, the problem is that the problem is that Removes the first row from the results given below the column name, it seems that the column row is somehow counted as a line in the loop, which displays the results, but I can not understand it.
If I remove the column name code shown below all results are shown.
// Column names advance ($ title $ headline) {$ objPHPExcel- & gt; GetActiveSheet () - & gt; Set cell value $ Col ++; }
All the code shown below.
$ query = "SELECT * FROM`" $ _SESSION ['sess_table'] "Order by ID ASC"; If ($ result = $ mysqli- & gt; queries ($ query)) {$ objPHPExcel = new PHPExcel (); $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; SetTitle ($ excelTitle); $ Headingsrow = $ result-> Fetch_assoc (); $ Headings = array_keys ($ headingsrow); // column name $ line number = 1; $ Col = 'A'; Forex Currency ($ heading $ title) {$ objPHPExcel- & gt; GetActiveSheet () - & gt; Set cell value ($ col. $ RowNumber, $ heading); $ Col ++; } // result $ line number = 3; While ($ line = $ result-> fetch_row ()) {$ col = 'A'; Forex currency ($ line as $ line = & gt; $ cell) {$ objPHPExcel- & gt; GetActiveSheet () - & gt; Set cell value ($ col. $ RowNumber, $ cell); $ Col ++; } $ Line number ++; } $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; FreezPen ('A2'); $ ObjWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'excel5'); Header ('content-type: application / vnd.ms-excel'); Header ('content-dispute: attachment; filename =' '. $ ExcelFilename.' .xls' '); header (' cache-control: max-age = 0 '); $ ObjWriter- & gt; save (' php : // output '); go out ();}
In your code, / P> $ rowNumber = 1; $ Col = 'A'; Forex ($ heading $ title) {$ objPHPExcel-> getActiveSheet () -> Set cell value ($ col. $ RowNumber, $ heading); $ Col ++;} You have increased the cost of $ calls instead of raising $ line numbers.
Try it out,
$ rowNumber = 1; $ Col = 'A'; vs Native currency ($ heading $ title) {$ objPHPExcel-> getActiveSheet () -> Set cell value ($ col. $ RowNumber, $ heading); $ RowNumber ++;}
Comments
Post a Comment