Function getAsText
Description
Returns the dataset result of SQL query as formatted text.
Syntax
dataset.getAsText(String column_separator, String
row_separator, String value_delimiter, boolean addColumnNames)
Parameters
String column_separator - any specified column separator; examples: tab
‘\t’; comma ‘,’; semicolon ‘;’; space ’ ’ .
String row_separator - the specified row separator; examples: new line ‘\n’.
String value_delimiter - the specified value delimiter; example: double quote
‘"’.
boolean addColumnNames - true to add column names as a first row; or false.
Example //assuming the variable dataset contains a dataset
//you can create csv or tab delimited results
var csv = dataset.getAsText(‘,’,‘\n’,‘"’,true);
var tab = dataset.getAsText(‘\t’,‘\n’,‘"’,true);
Here is what I did:
I added the following two lines to the end of method and called it:
var tab = dataset.getAsText('\t','\n','"',true);
globals.SQL_HTML = tab
The report output in globals.SQL_HTML field was tab delimiter.
Can I link this to The ExcelMaker method or is there any other way to view or export it into Excel?
If you seperate columns with a semikolon, write everything to a text file ending “.csv” you should be able to open it directly with Excel without further dialogs or assistants.
Using the native servoy plugins, you need something like this:
var tab = dataset.getAsText('\t','\n','"',true);
var fileName = 'export.xls';
//Show a save dialog
var file = plugins.file.showFileSaveDialog(fileName);
//Write textual file
var success = plugins.file.writeTXTFile(file,tab);