Create CSV from List
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Lists,Tokens
Turns the items of a list into CSV (comma-separated values). Each item becomes a row, and you choose which columns to write.
The CSV can be saved as a .csv file in a portal folder, or kept in a token for the actions that follow. When it's saved as a file, the file's URL, path and a download link can be saved as tokens.
The list comes from an earlier action, such as Create List from SQL, Create List from JSON or Create List from Excel (.xlsx). In a listing, it can also be the listing's rows.
Typical Use Cases
- Export the rows of a listing or a query to a CSV file that users can download
- Build a CSV file to attach to an email with Send Email
- Build CSV text in a token, to send to an API with Server Request
- Create a semicolon- or tab-separated file for a system that expects that format
Don't use it to
- Create an Excel workbook. Use Create Excel from List instead.
- Export a large query result. Use Create Excel from SQL query, which doesn't need a list.
- Read a CSV file into a list. Use Create List from a CSV source instead.
- Send the file to the browser. This action only creates it. See Delivering the file.
Related Actions
| Action Name | Description |
|---|---|
| Create List from SQL | Creates a list from the rows of a query. |
| Create List from JSON | Creates a list from a JSON array. |
| Create List from a CSV source | Does the opposite: reads CSV text or a CSV file into a list. |
| Create Excel from List | Writes a list to an Excel (.xlsx) file. |
| Existing List as JSON | Writes a list as JSON instead of CSV. |
| Send Email | Sends the file as an attachment. |
| Redirect to URL | Sends the user to the file's download link. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| List Name | The name of the list to write, for example ContactsList. If it resolves to empty, the default list of the current context is used, for example the rows of a listing. If the list doesn't exist, the action fails. | Yes | empty string | Yes |
| Fields | The columns to write, in order. Each row has a CSV Name, which is the column header, for example Full Name, and a Value, for example [FirstName] [LastName]. In Value, tokens refer to the list item's properties first, then to the other tokens in the context. Hidden when Include All Fields is on. | Yes | empty | Yes, unless Include All Fields is on |
| Include All Fields | Writes every property of the list, using the property names as headers. Properties whose names start with __ are skipped. | No | false | No |
| Remove Field Names | Leaves out the header row. | No | false | No |
| Field Separator | The character between values: comma, semicolon, tab, pipe or colon. In expression mode, you can pass the name, for example semicolon, or the character itself, for example ;. Tab only works by name. Anything else is treated as a comma. | Yes | empty (comma) | Yes |
| Add inline separetor | Adds a first line sep=<separator>, for example sep=;. Excel reads this line and uses that separator when it opens the file. Other programs may treat it as data. | No | false | No |
| Criteria | Writes only the items that match. Each row has a Property, for example Status, and a Value, for example Active. An item must equal every value to be written. Values support tokens. | Yes (values) | empty | No |
| Storage Location | File saves the CSV as a file. Memory saves the CSV text in a token. | No | File | Yes |
| Output Token Name | Memory only. The token that receives the CSV text, for example ContactsCsv. | No | empty string | No |
| Ensure CSV file type is allowed in DNN File System. | File only. Adds csv to the site's allowed file extensions if it isn't there yet, so saving doesn't fail. See Considerations. | No | false | No |
| Encoding | File only. The text encoding of the file: UTF8, UTF16 or UTF32. The file is written without a byte order mark (BOM). | No | UTF8 | Yes |
| Folder | File only. The portal folder to save the file in. Select a folder, or in expression mode enter a folder path relative to the portal root, for example Exports/Contacts. Missing folders are created. | Yes | none selected | Yes |
| Pattern | File only. The file name, without the extension, for example Contacts-[DateTime:Now|yyyyMMdd]. .csv is always added. Leave empty for a random name. | Yes | empty string | No |
| Handle Duplicates | File only. What happens if a file with the same name already exists in the folder. Rename adds a unique suffix to the new file's name. Overwrite replaces the existing file. | No | Rename | No |
| Disable Force Download | File only. By default, the LinkClick URL makes the browser download the file. Turn this on to let the browser open it instead, if it can. Only affects the Store LinkClick Url token. | No | false | No |
Output Parameters Reference
Each output is optional. Enter a token name in the ones you need. The file outputs are only filled when Storage Location is File.
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Output Token Name | Memory only. Receives the CSV text. | No | empty string | No |
| Store Absolute URL | Receives the file's absolute URL, for example https://example.com/Portals/0/Exports/Contacts.csv. | No | empty string | No |
| Store Relative URL | Receives the file's URL relative to the site root, for example /Portals/0/Exports/Contacts.csv. | No | empty string | No |
| Store Physical Path | Receives the file's physical path on the server. | No | empty string | No |
| Store LinkClick Url | Receives a LinkClick URL for the file, for example /LinkClick.aspx?fileticket=.... | No | empty string | No |
CSV format
- Values that contain the separator, a double quote or a line break are wrapped in double quotes. Double quotes inside them are doubled, for example
"Say ""hi""". - Other values aren't quoted.
- Rows are separated by line breaks.
- Values are written as text, as they appear in the list or in the resolved Value tokens. Dates and numbers aren't reformatted. Format them in Value if you need a specific format.
Delivering the file
The action saves the file but doesn't send it to the user. To deliver it:
- Redirect the user to the Store LinkClick Url token with Redirect to URL
- Attach it to an email with Send Email, using the file's URL in Attach from Token
- Show a link to the file in a message or a page
Considerations
- Allowed file extensions. DNN only saves files whose extension is allowed. If
csvisn't allowed on your site, saving fails. Turn on Ensure CSV file type is allowed in DNN File System. or addcsvin the site's settings. The option changes the host list of allowed extensions. When the user running the action isn't an administrator, it also changes the end-user list, if the portal has its own. - Opening in Excel. Excel uses the computer's regional settings to pick the separator. If users see all values in one column, use
semicolonor turn on Add inline separetor. Because the file has no BOM, Excel may show accented or non-Latin characters wrongly when it opens the file directly. - Don't add the extension to Pattern.
Contacts.csvbecomesContacts.csv.csv. Characters that aren't allowed in file names make the action fail. - Folder access. The file is saved with the folder's permissions. Choose a folder that the users who download the file can read, and keep private data out of public folders.
- Old files. Each run creates a new file unless Handle Duplicates is
Overwrite. Clean up old files, for example with Delete File. - Action Grid. In a grid, you can hide a column from the export only, with the
[SpecialContext:SerializeCSV]token in the field's condition. For example,[MyCondition] == "hide" || [SpecialContext:SerializeCSV].
Examples
To understand how to use the below examples, please see Running Examples.
1. Export contacts to a CSV file
This action writes ContactsList to Exports/Contacts-<date>.csv, with three columns. The Name column combines two list properties. The LinkClick URL is saved in the ContactsFileUrl token, so a following Redirect to URL action can start the download.
{
"Title": "Create CSV from List",
"ActionType": "CSV",
"Description": "Export contacts",
"Parameters": {
"EntityName": "ContactsList",
"Fields": [
{
"name": "Name",
"value": "[FirstName] [LastName]"
},
{
"name": "Email",
"value": "[Email]"
},
{
"name": "Phone",
"value": "[Phone]"
}
],
"IncludeAllFields": false,
"RemoveFieldNames": false,
"FieldSeparator": {
"Expression": "",
"Value": "comma",
"IsExpression": false,
"Parameters": {}
},
"inlineSeparator": false,
"Criteria": [],
"StorageLocation": {
"Expression": "",
"Value": "File",
"IsExpression": false,
"Parameters": {}
},
"AddCsvToAllowedFileTypes": true,
"EncodingOption": "UTF8",
"Folder": {
"Expression": "Exports",
"Value": "",
"IsExpression": true,
"Parameters": {}
},
"Pattern": "Contacts-[DateTime:Now|yyyyMMdd]",
"Duplicates": "Overwrite",
"StoreLinkClick": "ContactsFileUrl",
"DisableForceDownload": false
}
}
2. Build semicolon-separated text in a token
This action writes every property of the active items in OrdersList as semicolon-separated text, without a header row. The text is saved in the OrdersCsv token instead of a file, for example to send in the body of a Server Request.
{
"Title": "Create CSV from List",
"ActionType": "CSV",
"Description": "Build the orders CSV for the API",
"Parameters": {
"EntityName": "OrdersList",
"IncludeAllFields": true,
"RemoveFieldNames": true,
"FieldSeparator": {
"Expression": "",
"Value": "semicolon",
"IsExpression": false,
"Parameters": {}
},
"inlineSeparator": false,
"Criteria": [
{
"name": "Status",
"value": "Active"
}
],
"StorageLocation": {
"Expression": "",
"Value": "Memory",
"IsExpression": false,
"Parameters": {}
},
"OutputTokenName": "OrdersCsv"
}
}
Revised 09/26/2026