Skip to content

This is simple library to generate csv files from database or from arrary with custome and db hearders

Notifications You must be signed in to change notification settings

RohanPhpDev/Codeigniter-CSV-Generation-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Codeigniter CSV Library


What it does:
Takes an active record result or a data array and creates an csv file. Also, it's capable of passing custom titles and filename. Nothing super special but it gets the job done!

Instructions:
Just drop it in your libraries folder.

To create from database result

<?php
public function export() {
	$this->load->library('excel');

	$record = $this->db->get('dbtable');

	$this->excel->filename = 'Demo';
	$this->excel->make_from_db($record);
	//if you want to custome header then pass an array as third parameter
	$custome_header=['Title1','Title2'];
	$this->excel->make_from_db($record,$custome_header);
}
?>

To Create from a custom array

<?php
public function export() {
	$titles = array('
		'field1', 'field2', 'field3'
	');
	$array = array();
	for ($i = 0; $i <= 100; $i++) {
		$array[] = array($i, $i+1, $i+2);
	}
	$this->excel->make_from_array($titles, $array);
}
?>


About

This is simple library to generate csv files from database or from arrary with custome and db hearders

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages