Home > php教程 > PHP源码 > PHPExcel导出时列过大问题解决办法

PHPExcel导出时列过大问题解决办法

WBOY
Release: 2016-06-08 17:20:40
Original
1043 people have browsed it

PHPExcel是一个php 操作excel表格的插件了,我们可以使用它来进行数据导入或导入操作,但有时我们需要一些特殊的列名,那么要如何操作。

<script>ec(2);</script>

今天导出Excel的时候,列不是固定的,而且有差不多几十个,横轴由’A’变为了’AA’,给导出时增加了难度,因为要去算列名称,不过换个方式想一下,发现是很有规律的26进制数。 发现秘诀后就好办了,发一个10进制转26进制的方法。

private function numberToStr26($n)
{
    $s = '';
    while ($n > 0) {
        $m = $n % 26;
        if ($m == 0) $m = 26;
        $s = chr($m + 64) . $s;
        $n = ($n - $m) / 26;
    }
    return $s;
}

看张效果图片

 

PHPExcel导出时列过大问题解决办法
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template