Giter Club home page Giter Club logo

excel's Introduction

bean/excel

这是一个Excel处理包,包含了ExcelReader和ExcelWriter、Helpers类,帮助你处理基本的Excel操作。

ExcelReander 类包主要负责读取Excel,智能的识别文件类型和读取文件,让你不在为导入的文件类型而烦恼,目前支持的格式有:xlsx ,xls,csv 。也就是说目前支持excel97-excel2003,excel2007和csv格式。

特性 :

  1. 自动判断传入文件类型
  2. 支持excel日期格式
  3. 支持公式计算值
  4. 支持自定义获取数据

使用实例 :

   use Excel/ExcelReader;
   // 实例化ExcelReader类
   $reader = new ExcelReader($realPath);
   // 粗暴的获取Excel数据
   $data = $reader->readExcel()->readSheet()->getData();
   // 也可以这样使用
   $excel = $reader->readExcel();
   $sheetNumber = $excel->sheetNumber;
   $sheetName = $excel->sheetName[0];
   $sheet = $excel->readSheet($sheetName);
   $columnCount = $sheet->column;
   $rowCount = $sheet->row;
   $data = $sheet->getData()

ExcelWriter 是Excel导出类

特性 :

  1. 支持写入xslx xls csv格式
  2. 支持设置字体颜色
  3. 支持设置单元格背景颜色
  4. 支持设置单元格宽度(指定和自适应)
  5. 支持合并单元格
  6. 支持设置单元格对齐方式(水平、垂直)
  7. 支持多sheet操作
  8. 支持保存文件和浏览器输出

使用实例 :

    $writer = new ExcelWriter();

    for ($i = 0; $i < 100; $i++){
        for ($j = 0; $j < 10; $j++){
            $data[$i][$j] = 'test ['.$i.']+['.$j.']';
        }
    }
    $writer->setWidth(range('A','J'))
        ->setValue($data)
        ->setFormat('xls')
        ->setAlignment(array('A1','C1'),'CENTER')
        ->setBackgroundColor(array('A1','C1'),'#ccccc')
        ->setAlignment(array('A2','C2'),'RIGHT')
        ->setActiveSheetName('Bean')
        ->outPut('test.xls');

为了方便上传的同学,提供一个Helpers上传文件类。

使用实例 :

    $help = new Helpers();
    if ($help->hasFile('file')){
        $file = $help->uploadFile('file');
        $fileExtension = $file->fileExtension();
        $fileName = $file->fileName();
        $fileSize = $file->fileSize();
        $fileMineType = $file->fileMineType();
    }else{
        echo '文件上传失败';
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.