search
Homephp教程PHP源码PHPExcel导出时列过大问题解决办法

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导出时列过大问题解决办法
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment