Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How to export data from a string to a CSV file

Avatar

Level 2

Hello,

i do have a string in a Livecycle Designer script object with a couple of rows with different entries divided by a semicolon:

COLUMN1;COLUMN2;COLUMN3

Entry1;Entry2;Entry3

Entry4;Entry5;Entry6

The goal is now to export this string from Livecycle Designer into a CSV file by clicking a button. Is there any solution suggested?

Thank you very much.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You can try creating a dataObject and then exporting it, you might get some warning messages popup but try this;

var csvData = "COLUMN1;COLUMN2;COLUMN3\r\n";

csvData += "Entry1;Entry2;Entry3\r\n";

csvData += "Entry4;Entry5;Entry6\r\n";

var pdf = event.target;

pdf.createDataObject("Data.csv", csvData);

pdf.exportDataObject({cName: "Data.csv"});

If you replace the last line with

pdf.exportDataObject({cName: "Data.csv", nLaunch: 2});

It will open in whatever .csv is registered for (Excel on my system)

Regards

Bruce

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

You can try creating a dataObject and then exporting it, you might get some warning messages popup but try this;

var csvData = "COLUMN1;COLUMN2;COLUMN3\r\n";

csvData += "Entry1;Entry2;Entry3\r\n";

csvData += "Entry4;Entry5;Entry6\r\n";

var pdf = event.target;

pdf.createDataObject("Data.csv", csvData);

pdf.exportDataObject({cName: "Data.csv"});

If you replace the last line with

pdf.exportDataObject({cName: "Data.csv", nLaunch: 2});

It will open in whatever .csv is registered for (Excel on my system)

Regards

Bruce

Avatar

Level 2

Perfect thank you, it works like a charm!