3.8.5 Exporting to Text File (CSV) Programmatically

The CSV export feature saves the report's tabular data into a text file, delimited by commas (default). This allows you to import the exported data into another program (e.g., spreadsheet) to make further manipulations. Multiple report tables are exported to the CSV file one-by-one.

The CSV formatter is included in the inetsoft.report.io package.

FileOutputStream os = new FileOutputStream(filename);

Builder builder = Builder.getBuilder(Builder.CSV, os);

builder.write(sheet);

os.close();

Use the DelimitedFormatter class directly to change the delimiter character. The following code segment changes the delimiter to a tab and quotes each field with a double quote.

FileOutputStream os = new FileOutputStream(filename);

DelimitedFormatter fmt = new DelimitedFormatter(os);

fmt.setDelimiter("\t");

fmt.setQuote("\"");

Builder builder = new Builder(fmt);

builder.write(sheet);

os.close();

<< 3.8.4 Exporting to RTF Programmatically © 1996-2013 InetSoft Technology Corporation (v11.4) 3.9 Portal Customization >>