Link | serve_csv |
Author | Jason Huck |
Category | File |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 14 Oct 2005 |
Updated | 28 Sep 2012 |
More by this author... |
Serves a CSV file. Optionally accepts an array of field names and an array of arrays, where each nested array represents one line of data.
If called within an inline without those parameters, the tag will use [field_names] and [rows_array].
inline( $connection, -sql=$sql ); found_count > 0 ? serve_csv; /inline;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'csv', -namespace='serve_', -optional='filename', -type='string', -optional='fields', -type='array', -optional='rows', -type='array', -priority='replace', -description='Serves a CSV file.' ); fail_if( !local_defined('fields') && !field_names->size, -1, '[serve_csv] must be called with an array of field names or be within an inline where[field_names] contains values.' ); fail_if( !local_defined('rows') && !rows_array->size, -1, '[serve_csv] must be called with an array of row data or be within an inline where [rows_array] contains values.' ); !local_defined('fields') ? local('fields' = field_names); !local_defined('rows') ? local('rows' = rows_array); local('out' = string); iterate(#fields, local('f')); #out += #f; loop_count == #fields->size ? #out += '\r\n' | #out += ','; /iterate; iterate(#rows, local('r')); iterate(#r, #f); #f = string(#f); #f->replace('"','""')&replace('\r\n','\n')&replace('\r','\n'); #out += '"' + #f + '"'; loop_count == #r->size ? #out += '\r\n' | #out += ','; /iterate; /iterate; file_serve( #out, -file=(local_defined('filename') ? #filename | 'results.csv'), -type='text/csv' ); /define_tag;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Line 64?