Home  >  Article  >  Backend Development  >  php generates column numbers in excel

php generates column numbers in excel

WBOY
WBOYOriginal
2016-07-25 08:55:221692browse
  1. /**

  2. * Use php code to generate serial numbers in excel or csv files
  3. */
  4. public function loop(){
  5. $loop = 0;
  6. $charnum = 65;

  7. for(; $loop < 150; $loop++){

  8. $quotient = intval($loop / 26);
  9. $remainder = $loop % 26;

  10. $f = $quotient>0? chr($charnum+$quotient-1) : '';

  11. $s = $remainder>=0? chr($charnum+$remainder) : '';
  12. echo $loop .' | '. $quotient .' | '. $remainder .' | '. $f . $s ."
    ";
  13. } // bbs.it-home.org
  14. }

复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn