php excel导出列超过26个字母处理
2024-09-18 21:45:07
/**
* String from columnindex
*
* @param int $pColumnIndex Column index (base 0 !!!)
* @return string
*/
public static function stringFromColumnIndex($pColumnIndex = 0)
{
// Using a lookup cache adds a slight memory overhead, but boosts speed
// caching using a static within the method is faster than a class static,
// though it's additional memory overhead
static $_indexCache = array(); if (!isset($_indexCache[$pColumnIndex])) {
// Determine column string
if ($pColumnIndex < 26) {
$_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex);
} elseif ($pColumnIndex < 702) {
$_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) .
chr(65 + $pColumnIndex % 26);
} else {
$_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) .
chr(65 + ((($pColumnIndex - 26) % 676) / 26)) .
chr(65 + $pColumnIndex % 26);
}
}
return $_indexCache[$pColumnIndex];
}
最新文章
- 转:入门Webpack,看这篇就够了
- IOS学习笔记之获取Plist文件读取数据
- DB2常用命令
- SQL2008全部数据导出导入两种方法【转】
- C#调用脚本语言(三)-- IronJS 与 IronLua 简单方法性能比较
- Hybrid App开发者一定不要错过的框架和工具
- Linux RAR 安装和使用详细说明
- 【CKEditor ASP.NET】解决360安全浏览器极速模式下不显示
- 移植ffmpeg到VC环境心得
- 关于jsp页面 title中文乱码问题的解决方法
- Java 9 揭秘(14. HTTP/2 Client API)
- oracle中文乱码问题解决
- ubuntu Pycharm 2017 3.3 Active
- beta冲刺6/7
- docker 小结
- 设计 MySQL 数据表的时候一般都有一列为自增 ID,这样设计原因是什么,有什么好处?
- 非常精简的Linux线程池实现(一)——使用互斥锁和条件变量
- MySQL-慢查询日志
- django http404 详解
- linux网络配置练习