public IndicatorEntryCalcTemplate(final IndicatorEntryData data, final SpreadsheetDocument exDoc)
      throws Throwable {
    this.data = data;

    Table table = null;
    String tableName = data.getLocalizedVersion("flexibleElementIndicatorsList").replace(" ", "_");
    if (exDoc == null) {
      doc = SpreadsheetDocument.newSpreadsheetDocument();
      table = doc.getSheetByIndex(0);
      table.setTableName(tableName);
    } else {
      doc = exDoc;
      table = doc.appendSheet(tableName);
    }

    coreCellStyle = CalcUtils.prepareCoreStyle(doc);

    int rowIndex = -1;
    int cellIndex = 0;

    // skip row
    ++rowIndex;

    // title
    CalcUtils.putMainTitle(
        table,
        ++rowIndex,
        data.getNumbOfCols(),
        data.getLocalizedVersion("flexibleElementIndicatorsList").toUpperCase());

    // emptry row
    CalcUtils.putEmptyRow(table, ++rowIndex);

    // column headers
    row = table.getRowByIndex(++rowIndex);
    cellIndex = 0;
    CalcUtils.putHeader(row, ++cellIndex, data.getLocalizedVersion("name"));
    CalcUtils.putHeader(row, ++cellIndex, data.getLocalizedVersion("code"));
    CalcUtils.putHeader(row, ++cellIndex, data.getLocalizedVersion("targetValue"));
    CalcUtils.putHeader(row, ++cellIndex, data.getLocalizedVersion("value"));
    row.setHeight(5, false);

    // empty row
    row = table.getRowByIndex(++rowIndex);
    row.setHeight(3.8, false);
    row.getCellByIndex(1).setCellStyleName(null);
    row.getCellByIndex(2).setCellStyleName(null);
    row.getCellByIndex(3).setCellStyleName(null);
    row.getCellByIndex(4).setCellStyleName(null);

    for (final IndicatorGroup group : data.getIndicators().getGroups()) {
      row = table.getRowByIndex(++rowIndex);
      CalcUtils.putGroupCell(table, 1, rowIndex, group.getName());
      CalcUtils.mergeCell(table, 1, rowIndex, data.getNumbOfCols(), rowIndex);
      for (final IndicatorDTO indicator : group.getIndicators()) {
        // indicator's detail sheet
        createDetailSheet(indicator);
        row = table.getRowByIndex(++rowIndex);
        // ind name
        cell = CalcUtils.createBasicCell(table, 1, rowIndex, null);
        CalcUtils.applyLink(
            cell,
            indicator.getName(),
            ExportConstants.INDICATOR_SHEET_PREFIX + indicator.getName());
        // code
        CalcUtils.createBasicCell(table, 2, rowIndex, indicator.getCode());
        // target
        putValueCell(table, rowIndex, 3, indicator.getObjective(), true);
        // current value
        putValueCell(table, rowIndex, 4, data.getFormattedValue(indicator), true);
      }
    }

    table.getColumnByIndex(0).setWidth(3.8);
    table.getColumnByIndex(1).setWidth(83);
    table.getColumnByIndex(2).setWidth(55);
    table.getColumnByIndex(3).setWidth(55);
    table.getColumnByIndex(4).setWidth(55);
  }
  @Override
  public void export(OutputStream output) throws Exception {
    // The project id.
    final String idString = requireParameter(RequestParameter.ID);
    final Integer projectId;

    try {

      projectId = Integer.parseInt(idString);

    } catch (NumberFormatException e) {
      LOG.error("[export] The id '" + idString + "' is invalid.", e);
      throw new Exception("The id '" + idString + "' is invalid.", e);
    }

    try {

      // data
      final ProjectSynthesisData synthesisData = prepareSynthesisData(projectId);
      LogFrameExportData logFrameData = null;
      IndicatorEntryData indicatorData = null;

      // appending options
      final String typeString = requireParameter(RequestParameter.TYPE);
      final ExportUtils.ExportType type = ExportUtils.ExportType.valueOfOrNull(typeString);

      switch (type) {
        case PROJECT_SYNTHESIS_LOGFRAME:
          {
            final Project project =
                injector.getInstance(EntityManager.class).find(Project.class, projectId);
            logFrameData = SpreadsheetDataUtil.prepareLogFrameData(project, this);
          }
          break;

        case PROJECT_SYNTHESIS_INDICATORS:
          {
            indicatorData = SpreadsheetDataUtil.prepareIndicatorsData(projectId, this);
          }
          break;

        case PROJECT_SYNTHESIS_LOGFRAME_INDICATORS:
          {
            // logframe data
            final Project project =
                injector.getInstance(EntityManager.class).find(Project.class, projectId);
            logFrameData = SpreadsheetDataUtil.prepareLogFrameData(project, this);
            logFrameData.setIndicatorsSheetExist(true);
            // indicator data
            indicatorData = SpreadsheetDataUtil.prepareIndicatorsData(projectId, this);
          }
          break;

        default:
          // TODO Throw exception ?
          break;
      }

      ExportTemplate template = null;
      switch (exportFormat) {
        case XLS:
          {
            final HSSFWorkbook wb = new HSSFWorkbook();
            template =
                new ProjectSynthesisExcelTemplate(
                    synthesisData, wb, getContext(), getI18ntranslator(), getLanguage());
            if (logFrameData != null) template = new LogFrameExcelTemplate(logFrameData, wb);
            if (indicatorData != null)
              template = new IndicatorEntryExcelTemplate(indicatorData, wb);
          }
          break;

        case ODS:
          {
            final SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            template =
                new ProjectSynthesisCalcTemplate(
                    synthesisData, doc, getContext(), getI18ntranslator(), getLanguage());
            if (logFrameData != null) template = new LogFrameCalcTemplate(logFrameData, doc);
            if (indicatorData != null)
              template = new IndicatorEntryCalcTemplate(indicatorData, doc);
          }
          break;

        default:
          LOG.error("[export] The export format '" + exportFormat + "' is unknown.");
          throw new ServletException("The export format '" + exportFormat + "' is unknown.");
      }
      template.write(output);

    } catch (Throwable e) {
      LOG.error("[export] Error during the workbook writing.", e);
      throw new Exception("Error during the workbook writing.", e);
    }
  }