phpoffice 系列很好用。PhpSpreadSheet取代了原先的phpexcel,用来处理excel文件

https://phpspreadsheet.readthedocs.io/en/latest/

简单的使用示例:

1、基本操作

注意:新建和修改是不同的类来处理的

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use PhpOffice\PhpSpreadsheet\Writer\IWriter;

新建

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !'); $writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

修改

$spreadsheet = IOFactory::load($old_file);
$worksheet = $spreadsheet->getActiveSheet();
// 修改
$worksheet->getCell('A1')->setValue('John');
$worksheet->getCell('A2')->setValue('Smith'); $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save($new_file);

PhpSpreadSheet 读写excel文件的更多相关文章

  1. MFC vs2012 Office2013 读写excel文件

    近期在忙一个小项目(和同学一起搞的),在这里客户要求不但读写txt,而且可以读写excel文件,这里本以为很简单,结果...废话少说,过程如下: 笔者环境:win7 64+VS2012+Office2 ...

  2. 用Python读写Excel文件(转)

    原文:google.com/ncr 虽然天天跟数据打交道,也频繁地使用Excel进行一些简单的数据处理和展示,但长期以来总是小心地避免用Python直接读写Excel文件.通常我都是把数据保存为以TA ...

  3. C# 使用 NPOI 库读写 Excel 文件

    NPOI 是开源的 POI 项目的.NET版,可以用来读写Excel,Word,PPT文件.在处理Excel文件上,NPOI 可以同时兼容 xls 和 xlsx.官网提供了一份 Examples,给出 ...

  4. [转]用Python读写Excel文件

    [转]用Python读写Excel文件   转自:http://www.gocalf.com/blog/python-read-write-excel.html#xlrd-xlwt 虽然天天跟数据打交 ...

  5. python使用xlrd模块读写Excel文件的方法

    本文实例讲述了python使用xlrd模块读写Excel文件的方法.分享给大家供大家参考.具体如下: 一.安装xlrd模块 到python官网下载http://pypi.python.org/pypi ...

  6. python读写Excel文件的函数--使用xlrd/xlwt

    python中读取Excel的模块或者说工具有很多,如以下几种: Packages 文档下载 说明 openpyxl Download | Documentation | Bitbucket  The ...

  7. C++读写EXCEL文件OLE,java读写excel文件POI 对比

    C++读写EXCEL文件方式比较 有些朋友问代码的问题,将OLE读写的代码分享在这个地方,大家请自己看.http://www.cnblogs.com/destim/p/5476915.html C++ ...

  8. Python使用openpyxl读写excel文件

    Python使用openpyxl读写excel文件 这是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装.如果使用Aanconda,应该自带了. 读取E ...

  9. 使用phpexcel类读写excel文件

    使用原生php读写excel文件的博文地址: 基于使用原生php读写excel文件的不靠谱,本文将简单介绍如何使用第三方类库phpexcel来读写excel文件. 首先,需要到githut下载phpe ...

随机推荐

  1. windows 切换git远程仓库地址后 git push 提示Authentication failed

    git切换远程分支: 方法一: git remote set-url origin 你新的远程仓库地址 方法二: git remote rm origin git remote add origin ...

  2. 队列BlockingQueue的简单例子

    队列,当进行多线程编程的时候,很多时候可能会用到,队列是先进先出的,我们可以将要执行的任务放置在队列内缓存起来,当线程池中线程可以使用的时候,我们就从队列中获取一个任务执行.. 当前是一个队列的简单例 ...

  3. [Spring] Spring Data JPA

    Previouly we need to define a DAO interface and a DAO impl for 'Employee', it is not so reuseable, s ...

  4. HDU 6060 - RXD and dividing | 2017 Multi-University Training Contest 3

    /* HDU 6060 - RXD and dividing [ 分析,图论 ] | 2017 Multi-University Training Contest 3 题意: 给一个 n 个节点的树, ...

  5. javascript内置对象:Date

    JavaScript内置函数:Date时间<script>    var today=new Date();    weeks=["日","一",& ...

  6. Linux 防火墙遇到的问题

    一直报这个错误,写个博客来记录一下问题 在centos7中执行service iptables start 报如下错误 执行如下命令 systemctl stop firewalld systemct ...

  7. 在gitlab上删除分支后,本地git branch -r还能看到

    1. git remote prune --dry-run origin 查看当前有哪些是该消失还存在的分支 2. git remote prune origin 删除上面展示的所有分支 3. git ...

  8. Navicat创建连接

    https://blog.csdn.net/suprezheng/article/details/90037702 以下是不用创建直接可用的

  9. 请求返回模板定制,@RestControllerAdvice

  10. vector 与 array

    vector STL中的模板数组(在堆中分配内存空间,通过new delete管理内存) 使用包涵头文件#include <vector> vector<ElmentTpye> ...