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

Export-Data-java :: Version3.2

$
0
0

ExportData.java

The following sample code is for exporting data in table/report. In this example we export the "Sales Across Regions" chart as an PNG image. Also the data exported in the chart is filtered based on the following condition i.e. only data matching the following criteria will be displayed in the chart exported.

("Region" = 'Central') and ("Product Category" = 'Stationary')

Before trying it out

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

    public void exportData() throws Exception
    {
        String uri = rc.getURI(Config.LOGINEMAILID,Config.DATABASENAME,"Sales");
        File xmlFile = new File("Test.xml");
        rc.exportData(uri,"XML",xmlFile,null,null);
        System.out.println("Data successfully exported in xml format to" + xmlFile.getAbsolutePath());
        
        //Exports data with criteria.
        File csvFile = new File("Test.csv");
        rc.exportData(uri,"CSV",csvFile,getCriteria(),null);
        System.out.println("Data(filtered by criteria " + getCriteria() + ")\n successfully exported in csv format to " + csvFile.getAbsolutePath());
        String imgURI = rc.getURI(Config.LOGINNAME,Config.DATABASENAME,"Cost vs Sales");
        File imgFile = new File("SalesInfo.png");
        rc.exportData(imgURI,"IMAGE",imgFile,null,null);
        System.out.println("The image successfully exported as png to   " + imgFile.getAbsolutePath());
    }

    private static String getCriteria()
    {
        return "(\"Region\" = 'Central') and (\"Product Category\" = 'Stationary')";
    }

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

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

    }
}

Viewing all articles
Browse latest Browse all 71

Trending Articles