Quantcast
Channel: Zoho Reports API
Viewing all articles
Browse latest Browse all 71

ExportDataUsingSQL-java :: Version3.3

$
0
0

ExportDataUsingSQL.java

The following sample code exports/fetches data from Zoho Reports using a SQL SELECT query. This is done using Zoho Reports CloudSQL, which enables you to use SQL select query to fetch data from any of your Zoho Reports database.
 
In this example we are fetching the rows from the "Sales" table matching the " Region" as 'East" using a SELECT query.
Before trying it out
import java.io.*;
import com.adventnet.zoho.client.report.*;

public class ExportDataUsingSQL
{
    private ReportClient rc = Config.getReportClient();

    public void exportData() throws Exception
    {
        String uri = rc.getURI(Config.LOGINEMAILID,Config.DATABASENAME);
        String sql = "select "Customer Name",Sales,Cost,Profit from Sales where Region = 'East'";
        File expFile = new File("ExportedDataUsingSQL.csv");
        System.out.println("Exporting data using sql." + sql);
        rc.exportDataUsingSQL(uri,"CSV",expFile,sql,null);
        System.out.println("Data successfully exported to  " + expFile.getAbsolutePath());
    }


    public static void main(String[] args) throws Exception
    {
        ExportDataUsingSQL exp = new ExportDataUsingSQL();

        //call EXPORT API with the same logged in session
        exp.exportData();

    }
}

Viewing all articles
Browse latest Browse all 71

Trending Articles