bariew / html2csv
Converts HTML content to csv
Installs: 7 107
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:helper
Requires
- bariew/phpquery: dev-master
This package is auto-updated.
Last update: 2024-12-16 16:10:06 UTC
README
Converts html to csv. Common case is when you already have all data for csv - rendered in html table. With this helper you can take your html content and place it into csv file. Default raw selector is 'thead, tr', and cell selector 'th, td' - but you may redefine them.
Usage:
// Loading data
$htmlContent = '<table>...some data </table>';
$csv = new Html2Csv($htmlContent);
$csv->toFile("report.csv");
exit(0);
// Advanced usage:
$csv = new Html2Csv($htmlContent, [
'cellDelimiter' => "\t",
'cellEnclosure' => '"',
'rowSelector' => 'div.row',
'cellSelector' => 'div.cell'
]);
return $csv->toArray();