Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Export to Excel - Configuration steps

    Hi I'm new to Smart GWT Power Edition. I have purchased smartgwtpower-3.0p.
    We are trying to export data from a list grid.
    Im using SmartGWT 3.0 and Oracle database on windows box.

    Can you please provide step by step configuration to export data from list grid.


    I have attached same of my DS file and List grid.

    public class ToolVersionDS extends BaseDataSource {

    private List<ToolVersionVO> verLst = null;

    public ToolVersionDS(List<ToolVersionVO> voLst)
    {
    super();
    this.verLst = voLst;

    DataSourceIntegerField pkField = new DataSourceIntegerField("verId","<b>Tool Version ID</b>");
    pkField.setHidden(true);
    pkField.setPrimaryKey(true);

    DataSourceTextField toolIdField = new DataSourceTextField("toolId", "<b>Tool ID</b>");
    DataSourceTextField toolNmField = new DataSourceTextField("toolNm", "<b>Tool Name</b>");
    DataSourceTextField toolAkaField = new DataSourceTextField("toolAka", "<b>Tool AKA</b>");
    DataSourceTextField toolAdminField = new DataSourceTextField("toolAdministrator", "<b>Tool Manager</b>");

    setFields(pkField, toolIdField, toolNmField, toolAkaField, toolAdminField);

    }

    protected void executeFetch(String requestId, DSRequest dsRequest, DSResponse response) {

    ListGridRecord[] records; // = new ListGridRecord[toolVerLstLen];

    if (verLst != null) {

    int count =0;
    records = new ListGridRecord[verLst.size()];

    for (Iterator<ToolVersionVO> iterator = verLst.iterator(); iterator.hasNext();)
    {
    ToolVersionVO verVo = (ToolVersionVO) iterator.next();

    ListGridRecord record = new ListGridRecord();

    record.setAttribute("editIcon", "edit.png");
    record.setAttribute("toolId", verVo.getToolId());
    record.setAttribute("verId", verVo.getVerId());
    record.setAttribute("toolNm", verVo.getToolName());
    record.setAttribute("toolAka", verVo.getToolAka());

    record.setAttribute("toolAdministrator", verVo.getToolAdministrator());

    records[count++] = record;
    }
    response.setData(records);
    response.setTotalRows(records.length);
    }
    processResponse(requestId, response);

    }
    }


    ===================================
    List Grid

    final ListGrid toolVerGrid = new ListGrid();
    toolVerGrid.setCanAutoFitFields(true);
    toolVerGrid.setCanEdit(false);
    toolVerGrid.setCanHover(true);

    toolVerGrid.setWidth100();
    toolVerGrid.setHeight100();

    ListGridField f01 = new ListGridField("toolId", "<b>Tool ID</b>");
    ListGridField f1 = new ListGridField("toolNm", "<b>Tool Name</b>");
    ListGridField f12 = new ListGridField("toolAdministrator", "<b>Tool Manager</b>");
    ListGridField f13 = new ListGridField("developerFocal", "<b>Tool Focal</b>");
    ListGridField f14 = new ListGridField("sme", "<b>SME</b>");


    toolVerGrid.setFields(f01, f12, f13, f14);

    ToolVersionDS tvDS = new ToolVersionDS(result);
    toolVerGrid.setDataSource(tvDS);
    toolVerGrid.setAutoFetchData(true);
    toolVerGrid.setShowFilterEditor(true);
    toolVerGrid.setCanResizeFields(true);
    toolVerGrid.setGroupByMaxRecords(4000);



    IButton exportButton = new IButton("Export");
    exportButton.setIcon("icons/excelExport.png");
    exportButton.setValign(VerticalAlignment.CENTER);

    //exportButton.setAlign(Alignment.RIGHT);


    exportButton.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event) {

    // exportAs is either XML or CSV, which we can do with requestProperties
    DSRequest dsRequestProperties = new DSRequest();
    dsRequestProperties.setExportAs((ExportFormat)EnumUtil.getEnum(ExportFormat.values(), "csv"));
    dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);

    toolVerGrid.exportClientData(dsRequestProperties);
    }
    });

  • #2
    What are the jars used for export excel.

    Also, would like ti know what are the dependent jars.

    Comment


    • #3
      Installation instructions are here.

      This also contains a link to .jar dependencies.

      Comment

      Working...
      X