Skip to content

DigitalPHP/PHP_XLSX_CSV_WRITER

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP_XLSX_CSV_WRITER

a php script to writte xlsx and csv file

Import CSV and XLSX writter

//imports writees
include_once( "./csv/csv.writer.php" );
include_once( "./xlsx/xlsx.writer.php" );
include_once( "./headers.writer.php" );

PHP_CSV_XLSX_WRITTER

This library is designed to be lightweight, and have minimal memory usage.

It is designed to output an Excel compatible spreadsheet in (Office 2007+) xlsx format, with just basic features supported:

  • supports PHP 5.2.1+
  • takes UTF-8 encoded input
  • multiple worksheets
  • supports currency/date/numeric cell formatting, simple formulas
  • supports basic cell styling
  • csv files

Writte your csv and xlsx files.

Simple PHP CLI example:

$data = array(
    array('year','month','amount'),
    array('2003','1','220'),
    array('2003','2','153.5'),
);

$writer = new XLSX_Writer();
$writer->addLines($data);
$writer->writeToFile( 'output.xlsx') ;

For CSV Files

include_once( "./xlsx/xlsx.writer.php" );
include_once( "./headers.writer.php" );

HeadersWriter::CSVSHeaders( 'test' );

$writter = new CSV_Writer();
$rows = array(
    array( 'id', 'content' ),
    array( '1', 'ananas' ),
    array( '2', 'water' ),
    array( '3', 'bread' ),
    array( '4', 'meat' ),
);

$writter->addLines( $rows );
$writter->writeToStdOut();
#Or to writte in a specific file
$writter->writeToFile( "filename", "mode" );
#without extension

For Excel Files

include_once( "./xlsx/xlsx.writer.php" );
include_once( "./headers.writer.php" );

HeadersWriter::XLXSHeaders( 'test' );

$writter = new XLSX_Writer();
$rows = array(
    array( 'id', 'content' ),
    array( '1', 'ananas' ),
    array( '2', 'water' ),
    array( '3', 'bread' ),
    array( '4', 'meat' ),
);

$writter->addLines( $rows );
$writter->writeToStdOut();

Or to writte in a specific file

$writter->writeToFile( "filename" );
#without extension
| id | content  |
| -- | -------- |
| 1  |  ananas  |
| 2  |  water   |
| 3  |  bread   |
| 4  |  meat    |

And for CSV File

"id","content"
"1",""ananas"
"2","water"
"3","bread"
"4","meat"

About

a php script to writte xlsx and csv files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%