Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: populate a crosstab excel template

$
0
0
$Col='A'; FirstLine=1;
while($ArrayData=getNextRow()){
    $Line=$FirstLine;
    $F->setCellValue($Col.$Line++, $ArrayData['date']);
    $F->setCellValue($Col.$Line++, $ArrayData['name']);
    $F->setCellValue($Col.$Line++, $ArrayData['address']);
    //others data
    $Col=PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($Col));
}
Replace getNextRows() with your function who return a array for a row or false (like mysqli_fetch_assoc()). $F is the sheet object (something like : $F=$objPHPExcel->getActiveSheet()).

The increment of $Col is 'hidden' : columnIndexFromString is in base 1 (A=1) and stringFromColumnIndex is in base 0 (A=0). Using the two methods this way, you have A ->1->B.

Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>