Skip to main content
Version: 1.28 (Current)

Create CSV from List

Audience: Low-code Engineers

Skill 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​

Action NameDescription
Create List from SQLCreates a list from the rows of a query.
Create List from JSONCreates a list from a JSON array.
Create List from a CSV sourceDoes the opposite: reads CSV text or a CSV file into a list.
Create Excel from ListWrites a list to an Excel (.xlsx) file.
Existing List as JSONWrites a list as JSON instead of CSV.
Send EmailSends the file as an attachment.
Redirect to URLSends the user to the file's download link.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
List NameThe 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.Yesempty stringYes
FieldsThe 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.YesemptyYes, unless Include All Fields is on
Include All FieldsWrites every property of the list, using the property names as headers. Properties whose names start with __ are skipped.NofalseNo
Remove Field NamesLeaves out the header row.NofalseNo
Field SeparatorThe 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.Yesempty (comma)Yes
Add inline separetorAdds 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.NofalseNo
CriteriaWrites 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)emptyNo
Storage LocationFile saves the CSV as a file. Memory saves the CSV text in a token.NoFileYes
Output Token NameMemory only. The token that receives the CSV text, for example ContactsCsv.Noempty stringNo
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.NofalseNo
EncodingFile only. The text encoding of the file: UTF8, UTF16 or UTF32. The file is written without a byte order mark (BOM).NoUTF8Yes
FolderFile 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.Yesnone selectedYes
PatternFile only. The file name, without the extension, for example Contacts-[DateTime:Now|yyyyMMdd]. .csv is always added. Leave empty for a random name.Yesempty stringNo
Handle DuplicatesFile 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.NoRenameNo
Disable Force DownloadFile 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.NofalseNo

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.

ParameterDescriptionSupports TokensDefaultRequired
Output Token NameMemory only. Receives the CSV text.Noempty stringNo
Store Absolute URLReceives the file's absolute URL, for example https://example.com/Portals/0/Exports/Contacts.csv.Noempty stringNo
Store Relative URLReceives the file's URL relative to the site root, for example /Portals/0/Exports/Contacts.csv.Noempty stringNo
Store Physical PathReceives the file's physical path on the server.Noempty stringNo
Store LinkClick UrlReceives a LinkClick URL for the file, for example /LinkClick.aspx?fileticket=....Noempty stringNo

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 csv isn't allowed on your site, saving fails. Turn on Ensure CSV file type is allowed in DNN File System. or add csv in 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 semicolon or 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.csv becomes Contacts.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​

tip

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