bariew / html2csv
Converts HTML content to csv
Installs: 7 370
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:helper
pkg:composer/bariew/html2csv
Requires
- bariew/phpquery: dev-master
This package is auto-updated.
Last update: 2025-10-16 17:49:38 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();