Unload the contents of the table into a text variable.


ts_table(iTable, "export_to_csv", bool bWithHeadings, string column_separator, string digit_separator, int start_row, int numrows, string csv_result);


Here:

iTable - table handle,

bWithHeadings - display table headers or not,

column_separator - column separator character - usually ";",

digit_separator - decimal separator - usually ",",

start_row - from which row to display the table,

num_rows - how many rows to display (if -1 - then display all);



Example


//***********************************************

// Import ts_table from text in CSV format

// and export to this format

// LABPP 2021

//***********************************************

int main()
{
       int iTable;
       object("create", "ts_table", iTable);

       string csvstr;
csvstr = "\"Heading 1\";\"Heading 2\";\"Heading 3\"\n\
\"Value 11 two quotes \"\" text\";123.3;\"Value 31\"\n\
\"Value 12\";321.21;\"Value 32\"";

       ts_table(iTable, "import_from_csv", csvstr, ";");
       string str;
       ts_table(iTable, "print_to_str", str);
       coutvar << str;

       string str2;
       ts_table(iTable, "export_to_csv", true, ";", "," , 0, -1, str2);
       coutvar << str2;

       object("delete", iTable);
}