279
Views
2
Comments
Solved
Advanced Excel create CSV file
Question

how to save the file AS CSV !??

2025-08-13 09-41-37
Shubham Sharma
Champion
Solution

Hi Omar,

To save a file as CSV in OutSystems, you can follow these steps:

Create a new action that returns the data you want to include in the CSV file as a list.

Use the "Text_Join" function to join the list of data into a single string, separated by commas.

Use the "Text_ToBinary" function to convert the string into a binary file.

Return the binary file as a response to the user, with the content type set to "text/csv" and the

 content-disposition set to "attachment" with a ".csv" extension.


Here's an example of what the code for this action might look like :

// Action to generate a CSV file

export function GenerateCSV(data: List of String): Binary

{

  // Join the list of data into a single string

  var csvString = Text_Join(data, ",");

  

  // Convert the string into a binary file

  var csvFile = Text_ToBinary(csvString);

  

  // Return the binary file as a response

  Response.ContentType = "text/csv";

  Response.AddHeader("Content-Disposition", "attachment; filename=data.csv");

  return csvFile;

}


you can modify this code according to your application or logic.

2025-08-13 09-41-37
Shubham Sharma
Champion
Solution

Hi Omar,

To save a file as CSV in OutSystems, you can follow these steps:

Create a new action that returns the data you want to include in the CSV file as a list.

Use the "Text_Join" function to join the list of data into a single string, separated by commas.

Use the "Text_ToBinary" function to convert the string into a binary file.

Return the binary file as a response to the user, with the content type set to "text/csv" and the

 content-disposition set to "attachment" with a ".csv" extension.


Here's an example of what the code for this action might look like :

// Action to generate a CSV file

export function GenerateCSV(data: List of String): Binary

{

  // Join the list of data into a single string

  var csvString = Text_Join(data, ",");

  

  // Convert the string into a binary file

  var csvFile = Text_ToBinary(csvString);

  

  // Return the binary file as a response

  Response.ContentType = "text/csv";

  Response.AddHeader("Content-Disposition", "attachment; filename=data.csv");

  return csvFile;

}


you can modify this code according to your application or logic.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.