Utitily class for exporting of CSV files.
More...
|
| __construct ($delimiter='comma', $enclosure='"', $mimetype = 'application/download', $bom = false) |
| Constructor for the csv export reader.
|
|
| __destruct () |
| Make sure that everything is closed when we are finished.
|
|
| add_data ($row) |
| Add data to the temporary file in csv format.
|
|
| download_file () |
| Download the csv file.
|
|
| print_csv_data ($return=false) |
| Echos or returns a csv data line by line for displaying.
|
|
| set_filename ($dataname, $extension='.csv') |
| Set the filename for the uploaded csv file.
|
|
|
static | download_array ($filename, array &$records, $delimiter='comma', $enclosure='"') |
| Creates a file for downloading an array into a deliminated format.
|
|
static | print_array (array &$records, $delimiter='comma', $enclosure='"', $return = false) |
| This will convert an array of values into a deliminated string.
|
|
|
string | $csvenclosure |
| $csvenclosure How fields with spaces and commas are enclosed.
|
|
string | $delimiter |
| $delimiter The name of the delimiter.
|
|
string | $filename |
| $filename The filename for the csv file to be downloaded.
|
|
string | $mimetype |
| $mimetype Mimetype of the file we are exporting.
|
|
string | $path |
| $path The directory path for storing the temporary csv file.
|
|
|
| send_header () |
| Output file headers to initialise the download of the file.
|
|
| set_temp_file_path () |
| Set the file path to the temporary file.
|
|
|
resource | $fp |
| $fp File pointer for the csv file.
|
|
Utitily class for exporting of CSV files.
- Copyright
- 2012 Adrian Greeve
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
csv_export_writer::__construct |
( |
| $delimiter = 'comma', |
|
|
| $enclosure = '"', |
|
|
| $mimetype = 'application/download', |
|
|
| $bom = false ) |
Constructor for the csv export reader.
- Parameters
-
string | $delimiter | The name of the character used to seperate fields. Supported types(comma, tab, semicolon, colon, cfg) |
string | $enclosure | The character used for determining the enclosures. |
string | $mimetype | Mime type of the file that we are exporting. |
boolean | $bom | If true, prefix file with byte order mark. |
◆ add_data()
csv_export_writer::add_data |
( |
| $row | ) |
|
Add data to the temporary file in csv format.
- Parameters
-
array | $row | An array of values. |
◆ download_array()
static csv_export_writer::download_array |
( |
| $filename, |
|
|
array & | $records, |
|
|
| $delimiter = 'comma', |
|
|
| $enclosure = '"' ) |
|
static |
Creates a file for downloading an array into a deliminated format.
This function is useful if you are happy with the defaults and all of your information is in one array.
- Parameters
-
string | $filename | The filename of the file being created. |
array | $records | An array of information to be converted. |
string | $delimiter | The name of the delimiter. Supported types(comma, tab, semicolon, colon, cfg) |
string | $enclosure | How speical fields are enclosed. |
◆ print_array()
static csv_export_writer::print_array |
( |
array & | $records, |
|
|
| $delimiter = 'comma', |
|
|
| $enclosure = '"', |
|
|
| $return = false ) |
|
static |
This will convert an array of values into a deliminated string.
Like the above function, this is for convenience.
- Parameters
-
array | $records | An array of information to be converted. |
string | $delimiter | The name of the delimiter. Supported types(comma, tab, semicolon, colon, cfg) |
string | $enclosure | How speical fields are enclosed. |
bool | $return | If true will return a string with the csv data. |
- Return values
-
◆ print_csv_data()
csv_export_writer::print_csv_data |
( |
| $return = false | ) |
|
Echos or returns a csv data line by line for displaying.
- Parameters
-
bool | $return | Set to true to return a string with the csv data. |
- Return values
-
◆ set_filename()
csv_export_writer::set_filename |
( |
| $dataname, |
|
|
| $extension = '.csv' ) |
Set the filename for the uploaded csv file.
- Parameters
-
string | $dataname | The name of the module. |
string | $extenstion | File extension for the file. |
◆ $delimiter
string csv_export_writer::$delimiter |
$delimiter The name of the delimiter.
Supported types(comma, tab, semicolon, colon, cfg)
The documentation for this class was generated from the following file: