PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 5, 2022

[FIXED] how implement cells more than Z in phpexcel?

 October 05, 2022     php, phpexcel     No comments   

Issue

$PHPExcel->getDefaultStyle()->getFont()->setName('Arial')
->setSize(10);

$PHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Linto')
->setCellValue('B1', 'Cheeran')
->setCellValue('A2', 'Sandhya');

$PHPExcel->getActiveSheet()->setCellValue('A5', 'date')
->setCellValue('B5', '31-12-2010');

if there are more cells, how control them in phpexcel ?

->setCellValue('A1', 'Linto')
->setCellValue('Z1', 'Linto')

after Z1 what is the representation of cell in next row and column ?


Solution

The column names used by PHPExcel match the column names seen in Excel. So after Z1, it goes to AA1, AB1, etc. (after AZ1 comes BA1).

So you can just use:

->setCellValue('AA1', 'Linto')

And as Mark pointed out, there is setCellValueByColumnAndRow which allow you to set cells using numeric indices:

->setCellValueByColumnAndRow($column, $row)

Note: that row is 1 based (i.e., row 1 is the first row) and column is 0 based (i.e., column 0 is the first column).



Answered By - Nathan P
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing