承接 agoussec/phpdbtabletoexcel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agoussec/phpdbtabletoexcel

Composer 安装命令:

composer require agoussec/phpdbtabletoexcel

包简介

Create Excel sheet directly from database table rows

README 文档

README

Create Excel sheet directly from database table's rows

Getting Started

PHPDBTabletoExcel is a very simple and easy to use PHP package for generating Excel file from database table SQL query.

It can connect to a database using PDO and executes a given SQL database table query.

The class executes the query and then outputs the results to a file in HTML table based format that is served for download and can be read and imported correctly by Microsoft Excel.

Prerequisites

No requirements for now!

Installing

Install using composer

composer require agoussec/phpdbtabletoexcel

Create Object of Class and start using it directly by adding in your project files if autoload is enabled, if not then include class file in your project.

use agoussec\class\Export;
$export = new Export();

Usage Example

Way 1 for initializing database connection

You can pass database credentials while creating object of class.

$exportObject = new Export('localhost', 'dbuser', 'password', 'database');

Way 2 for initializing database connection

Create PDO connection and pass PDO object to setConnection() method

$Conn = new PDO('mysql:host=localhost;dbname=dbname', 'dbuser', "dbpassword");
$export->setConnection($Conn);

Set SQL Query

$sql = "SELECT 
           table2.column1 as `Column 1`, 
           table3.column2 as `Column 2`, 
           table1.column3 as `Column 3`, 
        FROM `table1`
           left JOIN table2 ON table2.id = table1.table2id
           left JOIN table3 ON table3.id = table1.table3id 
        WHERE table1.status = 1";

 $export->setQuery($sql);

Set table rows (optional)

$export->setData($PDOFETCHEDARRAY);  

Exported File Name (optional)

$export->setFilename('setFilename');

Header row in exported excel sheet (optional)

$export->setHeaderRow(true);  

Time Stamp (optional)

$export->setTimestamp(true);

And at last get the Excel file -

$export->getFile();

Authors

  • Shamsh Pravez - Initial work - agoussec

License

This project is licensed under the GNU General Public License v3.0 - see the LICENCE file for details

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2021-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固