How to create a simple CSV report

As of 15-Oct-17 it is possible to create your own reports which export to CSV format rather than Excel, PDF or Word formats. This can be achieved by following the steps below:

Create a generic CSV export Add-in

In order to setup a generic CSV export Add-in, you can run the built-in setup script below via the Administration, Add-ins, Script editor.

Copy the code block provided below and paste it into the script editor window as shown below. The section labelled as "THE_NAME_OF_YOUR_ADDIN" will need to be changed to whatever the actual name of your CSV Add-in should be e.g Orders_Query_CSV.

When ready click Run:

Setup script
public class Script
{
  public void Main()
  {
    new FboOne.Scripts.GenericCsvFormatterSetup().Main("THE_NAME_OF_YOUR_ADDIN");
  }
}

Configuring the generic CSV exporting Add-in

Using Administration | Add-ins menu section you can view and edit your newly created Add-in.

Configuration settings can be entered in the "Config string" section, each setting delimited from the other by a semi colon character, for example: GenerateAllQueryColumns=false;Separator="|";FileName="order-services.csv"

GenerateAllQueryColumns (default = true) - by default, when running a custom report all report query columns are generated and added to the report query so that values are provided in case these are needed/mentioned in the report template. This setting makes it possible to disable this feature so that your CSV report only outputs the desired columns in the order you mention them

Separator (default = ",") - you can specify a different separator from the default "," one. Don't forget to place the desired separator between ""

FileName (default = "GenericCsvOutput.csv") - you can specify the output file name with extension. Don't forget to place the desired separator between ""

Setting up the report that uses the new CSV Addin

By navigating to Administration | Reports menu section you can create your own report that is using the newly create Addin as a custom formatter.

The column offset is used in this case to specify the order of the columns in the output/export file

By checking "Show column names" check box in the report query, column header is displayed in the export csv file

Column aliases can be used to specify a different column header name.

Individual columns, like DateTime and Decimal value columns, can be formatted so that the output is the desired one.

Following link provides more details on possible DateTime column formats: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Following link provides more details on possible Decimal column formats: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings

Exporting your custom CSV file

This is done like any other report is executed in FBO One. Simply navigate to your Reports section, select your newly created report, add the filter parameters and click for the report to be generated

 

Example of simple csv export without header section:

Export example with header section and alias used instead of column name:

Export example with formatted DateTime and Decimal columns: