fobia/php-tablesheet

PHP Table Sheet

维护者

详细信息

github.com/faclib/TableSheet

源代码

安装: 17

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

语言:HTML

v0.1 2015-05-07 13:31 UTC

This package is auto-updated.

Last update: 2024-09-06 23:51:49 UTC


README

Build Status

将表格转换为标准CSV格式

安装

安装

$ sudo apt-get install python python-pip
$ sudo pip install --requirement=requirements.txt
$ composer install 

requirements.txt

chardet==2.3.0
xlrd==0.9.3
xlsx2csv==0.7.1
xlutils==1.7.1
xlwt==0.7.5

用法

toCSV()

Fobia\TableSheet::toCSV($pFilename, $outfile, $options)

参数

  • pFilename String 读取文件的名称。
  • outfile String 写入文件的路径。
  • options Array 参数。
    • delimiter String (optional, default: ,) 分隔符

toXLS()

Fobia\TableSheet::toXLS($csvFile, $output, $options)

参数

  • csvFile String 读取文件的名称。
  • output String 写入文件的路径。
  • options Array 参数。
    • sheetname String (optional, default: Sheet1) 工作表名称。
    • head_color String (optional, default: null) 设置标题颜色(#F4ECC5)[红色,黄色,蓝色]
    • forse String (optional, default: false) 尝试预先转换文件格式

Python用法

语法

$ python convert-table.py <command> [options] <infile> <outfile>

, 其中

  • command String (csv, xls) 命令。
  • infile String 输入文件
  • outfile String 输出文件(CSV,XLS)

csv - 转换为CSV

  • --delimiter <D> String (optional, default: ,) csv中列的分隔符(默认:',')

xls - 转换为XLS

  • --forse 预先转换为csv
  • --sheetname <S> String (optional, default: Sheet1) 保存的工作表名称
  • --head 冻结标题
  • --color <C> String (optional) 标题背景颜色

转换为正确的CSV格式,分隔符 ,

$ python convert-table.py csv in.xls out.csv
$ python convert-table.py csv --delimetr ';' in.xls out.csv

转换为Excel表格

$ python convert-table.py xls in.csv out.xls
$ python convert-table.py xls --forse  in.oter out.xls
$ python convert-table.py xls --head --color '#FFCC00' in.csv out.xls