Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@woocommerce/csv-export
Advanced tools
WooCommerce utility library to convert data to CSV files.
A set of functions to convert data into CSV values, and enable a browser download of the CSV data.
Install the module
pnpm install @woocommerce/csv-export --save
onClick = () => {
// Create a file name based on a title and optional query. Will return a timestamped
// name, for example: revenue-2018-11-01-interval-month.csv
const name = generateCSVFileName( 'revenue', { interval: 'month' } );
// Create a string of CSV data, `headers` is an array of row headers, put at the top
// of the file. `rows` is a 2 dimensional array. Each array is a line in the file,
// separated by newlines. The second-level arrays are the data points in each row.
// For header format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=headers-2
// For rows format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=rows-1
const data = generateCSVDataFromTable( headers, rows );
// Triggers a browser UI to save a file, named the first argument, with the contents of
// the second argument.
downloadCSVFile( name, data );
}
String
Generates a CSV string from table contents
Returns: String
- Table contents in a CSV format
Param | Type | Description |
---|---|---|
headers | Array.<Object> | Object with table header information |
rows | Array.Array.<Object> | Object with table rows information |
String
Generates a file name for CSV files based on the provided name, the current date and the provided params, which are all appended with hyphens.
Returns: String
- Formatted file name
Param | Type | Default | Description |
---|---|---|---|
[name] | String | '' | Name of the file |
[params] | Object | {} | Object of key-values to append to the file name |
Downloads a CSV file with the given file name and contents
Param | Type | Description |
---|---|---|
fileName | String | Name of the file to download |
content | String | Contents of the file to download |
FAQs
WooCommerce utility library to convert data to CSV files.
The npm package @woocommerce/csv-export receives a total of 1,054 weekly downloads. As such, @woocommerce/csv-export popularity was classified as popular.
We found that @woocommerce/csv-export demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.