search
Homephp教程php手册输出EXCEL文件
输出EXCEL文件Jun 06, 2016 pm 07:31 PM
excelphpusedocumentreadoutput

使用php读取excel文件 PHP PHPExcel ?phprequire_once( FCPATH.'vendor/Excel/excel/PHPExcel/IOFactory.php');function readexcel( $filePath) { $PHPReader = new PHPExcel_Reader_Excel5(); if(!$PHPReader-canRead($filePath)){ $PHPReader = new PHPExce

使用php读取excel文件 PHP PHPExcel
<?php
require_once( FCPATH.'vendor/Excel/excel/PHPExcel/IOFactory.php');

function readexcel( $filePath) { 
$PHPReader = new PHPExcel_Reader_Excel5();
         if(!$PHPReader->canRead($filePath)){   
             $PHPReader = new PHPExcel_Reader_Excel5();   
                   if(!$PHPReader->canRead($filePath)){         
                        echo 'no Excel';  
                         return ;   
                   }  
          }

$PHPExcel = $PHPReader->load($filePath);  

$currentSheet = $PHPExcel->getSheet(0);  /**取得一共有多少列*/ 

$allColumn = $currentSheet->getHighestColumn();     /**取得一共有多少行*/  

$allRow = $currentSheet->getHighestRow();

$all = array();
for( $currentRow = 1 ; $currentRow <= $allRow ; $currentRow++){

          $flag = 0;
          $col = array();
          for($currentColumn='A'; getascii($currentColumn) <= getascii($allColumn) ; $currentColumn++){
             
                $address = $currentColumn.$currentRow;   

                $string = $currentSheet->getCell($address)->getValue();
                
                $col[$flag] = $string;

                $flag++;
          } 

      $all[] = $col;
}

return $all;
}

function getascii( $ch) {
  if( strlen( $ch) == 1)
    return ord( $ch)-65;
  return ord($ch[1])-38;
}
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
一文教会你Excel折叠表格分类汇总功能一文教会你Excel折叠表格分类汇总功能May 12, 2022 am 11:58 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于折叠表格的相关问题,就是分类汇总的功能,这样查看数据会非常的方便,下面一起来看一下,希望对大家有帮助。

实用Excel技巧分享:计算年数差、月数差、周数差实用Excel技巧分享:计算年数差、月数差、周数差Apr 22, 2022 am 09:56 AM

在之前的文章《实用Excel技巧分享:利用 数据透视表 来汇总业绩》中,我们学习了下Excel数据透视表,了解了利用数据透视表来汇总业绩的方法。而今天我们来聊聊怎么计算时间差(年数差、月数差、周数差),希望对大家有所帮助!

Word与Excel联动:表格借用Word进行分栏打印!Word与Excel联动:表格借用Word进行分栏打印!May 07, 2022 am 10:28 AM

在之前的文章《实用Word技巧分享:聊聊你没用过的“行号”功能》中,我们了解了Word中你肯定没用过的"行号”功能。今天继续实用Word技巧分享,看看Excel表格怎么借用Word进行分栏打印,快来收藏使用吧!

实用Excel技巧分享:合并单元格后实现筛选功能实用Excel技巧分享:合并单元格后实现筛选功能May 11, 2022 am 10:22 AM

在之前的文章《实用Excel技巧分享:原来“定位功能”这么有用!》中,我们了解了定位功能的妙用。而今天我们聊聊合并后的单元格如何实现筛选功能,分享一种复制粘贴和方法解决这个问题,另外还会给大家分享一种合并单元格的不错的替代方式。

图文详解Excel中XLOOKUP函数典型用法整理图文详解Excel中XLOOKUP函数典型用法整理Apr 21, 2022 am 11:46 AM

本篇文章给大家带来了关于Excel的相关知识,其中主要介绍了关于XLOOKUP函数的相关知识,包括了常规查询、逆向查询、返回多列、自动除错以及近似查找等内容,下面一起来看一下,希望对大家有帮助。

图文详解Excel的折线图图文详解Excel的折线图May 07, 2022 am 11:28 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于折线图的相关问题,下面就根据一些示例来看一下怎么去应用,希望对大家有帮助。

一起聊聊操作简单又高效的Excel数据透视表一起聊聊操作简单又高效的Excel数据透视表Apr 26, 2022 pm 12:07 PM

本篇文章给大家带来了关于Excel的相关知识,其中主要介绍了操作简单又高效的Excel数据透视表相关操作,包括了创建动态数据范围的数据透视表、二维表转换为一维表等等内容,下面一起来看一下,希望对大家有帮助。

Excel技巧总结之批量创建工作表Excel技巧总结之批量创建工作表Apr 27, 2022 pm 12:01 PM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于批量创建工作表的相关问题,总结了一个小技巧,下面一起来看一下,希望对大家有帮助。

See all articles

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

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),