国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php生成excel列名,超過26列大于Z問題解決辦法

2024-05-04 21:49:10
字體:
來源:轉載
供稿:網友

我們生成excel都會使用phpExcel類了,下面我來給大家介紹在生成excel列名超過26列大于Z問題解決辦法吧,這是phpExcel類中的方法,今天查到了,記錄一下備忘,代碼如下:

  1. public static function stringFromColumnIndex($pColumnIndex = 0)  
  2.     {  
  3.         //  Using a lookup cache adds a slight memory overhead, but boosts speed  
  4.         //  caching using a static within the method is faster than a class static,  
  5.         //      though it's additional memory overhead  
  6.         static $_indexCache = array();  
  7.    
  8.         if (!isset($_indexCache[$pColumnIndex])) {  
  9.             // Determine column string  
  10.             if ($pColumnIndex < 26) {  
  11.                 $_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex);  
  12.             } elseif ($pColumnIndex < 702) {  
  13.                 $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) .  
  14.                                               chr(65 + $pColumnIndex % 26);  
  15.             } else { //開源代碼Vevb.com 
  16.                 $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) .  
  17.                                               chr(65 + ((($pColumnIndex - 26) % 676) / 26)) .  
  18.                                               chr(65 + $pColumnIndex % 26);  
  19.             }  
  20.         }  
  21.         return $_indexCache[$pColumnIndex];  
  22.     } 

將列的數字序號轉成字母使用,代碼如下:

PHPExcel_Cell::stringFromColumnIndex($i); // 從o開始

將列的字母轉成數字序號使用,代碼如下:

PHPExcel_Cell::columnIndexFromString(‘AA’);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莱阳市| 扶风县| 水城县| 寿宁县| 乐平市| 吴忠市| 大同市| 潜江市| 天峨县| 彰化市| 康乐县| 昌吉市| 丹凤县| 客服| 新津县| 东乡族自治县| 满洲里市| 湘潭县| 印江| 贡嘎县| 嘉鱼县| 开封县| 纳雍县| 海盐县| 乡宁县| 黔西| 博乐市| 和硕县| 汉川市| 章丘市| 偃师市| 都安| 聂荣县| 浮梁县| 天柱县| 新源县| 弥勒县| 永泰县| 邹平县| 永泰县| 永昌县|