it.eng.spagobi.engines.qbe.crosstable.exporter
Class CrosstabXLSXExporter

java.lang.Object
  extended by it.eng.spagobi.engines.qbe.crosstable.exporter.CrosstabXLSXExporter

public class CrosstabXLSXExporter
extends java.lang.Object

Exports the crosstab data (formatted as a JSON object in input) into a XLS file. The JSON object should have this structure (a node is {node_key:"Text", node_childs:[...]}): columns: {...} contains tree node structure of the columns' headers rows: {...} contains tree node structure of the rows' headers data: [[...], [...], ...] 2-dimensional matrix containing crosstab data

Author:
Davide Zerbetto (davide.zerbetto@eng.it)

Field Summary
static org.apache.log4j.Logger logger
          Logger component.
 
Constructor Summary
CrosstabXLSXExporter()
           
 
Method Summary
 org.apache.poi.ss.usermodel.CellStyle buildDataCellStyle(org.apache.poi.ss.usermodel.Sheet sheet)
           
 org.apache.poi.ss.usermodel.CellStyle buildHeaderCellStyle(org.apache.poi.ss.usermodel.Sheet sheet)
           
 int commonFillSheet(org.apache.poi.ss.usermodel.Sheet sheet, org.json.JSONObject json, org.apache.poi.ss.usermodel.CreationHelper createHelper, int startRow)
           
 org.apache.poi.ss.usermodel.Workbook export(org.json.JSONObject json)
          Exports the crosstab data (formatted as a JSON object in input) into a XLS file.
 int fillAlreadyCreatedSheet(org.apache.poi.ss.usermodel.Sheet sheet, org.json.JSONObject json, org.apache.poi.ss.usermodel.CreationHelper createHelper, int startRow)
           
 void fillSheet(org.apache.poi.ss.usermodel.Sheet sheet, org.json.JSONObject json, org.apache.poi.ss.usermodel.CreationHelper createHelper)
           
 int initSheet(org.apache.poi.ss.usermodel.Sheet sheet, org.json.JSONObject json)
          Sheet initialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static transient org.apache.log4j.Logger logger
Logger component.

Constructor Detail

CrosstabXLSXExporter

public CrosstabXLSXExporter()
Method Detail

export

public org.apache.poi.ss.usermodel.Workbook export(org.json.JSONObject json)
                                            throws org.json.JSONException,
                                                   it.eng.qbe.serializer.SerializationException
Exports the crosstab data (formatted as a JSON object in input) into a XLS file. The JSON object should have this structure (a node is {node_key:"Text", node_childs:[...]}): columns: {...} contains tree node structure of the columns' headers rows: {...} contains tree node structure of the rows' headers data: [[...], [...], ...] 2-dimensional matrix containing crosstab data

Parameters:
json - The crosstab data serialization
Returns:
the Workbook object (the XLS file)
Throws:
org.json.JSONException
it.eng.qbe.serializer.SerializationException

fillSheet

public void fillSheet(org.apache.poi.ss.usermodel.Sheet sheet,
                      org.json.JSONObject json,
                      org.apache.poi.ss.usermodel.CreationHelper createHelper)
               throws org.json.JSONException,
                      it.eng.qbe.serializer.SerializationException
Throws:
org.json.JSONException
it.eng.qbe.serializer.SerializationException

fillAlreadyCreatedSheet

public int fillAlreadyCreatedSheet(org.apache.poi.ss.usermodel.Sheet sheet,
                                   org.json.JSONObject json,
                                   org.apache.poi.ss.usermodel.CreationHelper createHelper,
                                   int startRow)
                            throws org.json.JSONException,
                                   it.eng.qbe.serializer.SerializationException
Throws:
org.json.JSONException
it.eng.qbe.serializer.SerializationException

commonFillSheet

public int commonFillSheet(org.apache.poi.ss.usermodel.Sheet sheet,
                           org.json.JSONObject json,
                           org.apache.poi.ss.usermodel.CreationHelper createHelper,
                           int startRow)
                    throws it.eng.qbe.serializer.SerializationException,
                           org.json.JSONException
Throws:
it.eng.qbe.serializer.SerializationException
org.json.JSONException

initSheet

public int initSheet(org.apache.poi.ss.usermodel.Sheet sheet,
                     org.json.JSONObject json)
              throws org.json.JSONException
Sheet initialization. We create as many rows as it is required to contain the crosstab.

Parameters:
sheet - The XLS sheet
json - The crosstab data (it must have been enriched with the calculateDescendants method)
Throws:
org.json.JSONException

buildHeaderCellStyle

public org.apache.poi.ss.usermodel.CellStyle buildHeaderCellStyle(org.apache.poi.ss.usermodel.Sheet sheet)

buildDataCellStyle

public org.apache.poi.ss.usermodel.CellStyle buildDataCellStyle(org.apache.poi.ss.usermodel.Sheet sheet)