Package org.molgenis.io.excel

Examples of org.molgenis.io.excel.ExcelWriter


  }

  @Override
  public void export(OutputStream os) throws TableException
  {
    ExcelWriter excelWriter = new ExcelWriter(os);
    try
    {
      // save table state
      int colOffset = tupleTable.getColOffset();
      int colLimit = tupleTable.getColLimit();
      int rowOffset = tupleTable.getOffset();
      int rowLimit = tupleTable.getLimit();

      // update table state
      tupleTable.setColOffset(0);
      tupleTable.setColLimit(0);
      tupleTable.setOffset(0);
      tupleTable.setLimit(0);

      TupleWriter tupleWriter = excelWriter.createTupleWriter("Sheet1");
      try
      {
        // write header row
        tupleWriter.writeColNames(Iterables.transform(tupleTable.getColumns(), new Function<Field, String>()
        {
View Full Code Here


    FormController<?> controller = ((FormController<?>) this.getController());

    List<String> fieldsToExport = controller.getVisibleColumnNames();

    QueryRule[] rules = model.getRulesExclLimitOffset();
    ExcelWriter excelWriter = new ExcelWriter(xlsDownload);
    try
    {
      Class<? extends Entity> entityClass = model.getController().getEntityClass();
      db.find(entityClass, excelWriter.createTupleWriter(entityClass.getSimpleName()), fieldsToExport, rules);
    }
    finally
    {
      excelWriter.close();
    }

    return ScreenModel.Show.SHOW_MAIN;
  }
View Full Code Here

  public ScreenModel.Show handleRequest(Database db, MolgenisRequest request, OutputStream xlsDownload)
      throws ParseException, DatabaseException, Exception
  {
    FormModel<?> view = this.getFormScreen();
    List<String> fieldsToExport = ((FormController<?>) this.getController()).getVisibleColumnNames();
    ExcelWriter excelWriter = new ExcelWriter(xlsDownload);
    TupleWriter sheetWriter = excelWriter.createTupleWriter("Entity");

    try
    {
      sheetWriter.writeColNames(fieldsToExport);

      for (Entity e : view.getRecords())
        sheetWriter.write(new EntityTuple(e));
    }
    finally
    {
      excelWriter.close();
    }

    return ScreenModel.Show.SHOW_MAIN;
  }
View Full Code Here

      return ScreenModel.Show.SHOW_MAIN;
    }

    List<String> fieldsToExport = ((FormController<?>) this.getController()).getVisibleColumnNames();

    ExcelWriter excelWriter = new ExcelWriter(xlsDownload);
    try
    {
      Class<? extends Entity> entityClass = model.getController().getEntityClass();
      db.find(model.getController().getEntityClass(), excelWriter.createTupleWriter(entityClass.getSimpleName()),
          fieldsToExport, new QueryRule("id", Operator.IN, records));
    }
    finally
    {
      excelWriter.close();
    }
    return ScreenModel.Show.SHOW_MAIN;
  }
View Full Code Here

TOP

Related Classes of org.molgenis.io.excel.ExcelWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.