- <?php
- /**
- * 获取excel表格里指定单元的名称索引:
- * 如第1行第1列:
- * 返回A1
- * 第27行第二列:
- * 返回AA1:
- *
- * @param int $row 第几行
- * @param int $col 第几列
- *
- * @author mingche
- * @since 2014-05-31
- */
- function getExcelCeilIndex($row, $col) {
- if($row > 0 && $col > 0 )
- {
- $str = "ZABCDEFGHIGKLMNOPQRSTUVWXY";
- $col_str = "";
- do
- {
- $col_tmp = $col % 26;
- $col = $col_tmp == 0 ? intval($col / 26) - 1 : intval($col / 26);
- $col_str = $str[$col_tmp].$col_str;
- }while( $col );
- return $col_str.$row;
- }
- return false;
- }
- ?>
- //该片段来自于http://www.codesnippet.cn/detail/030620149701.html
来源: http://www.codesnippet.cn/detail/030620149701.html