Example usage for org.apache.poi.ss.util WorkbookUtil createSafeSheetName

List of usage examples for org.apache.poi.ss.util WorkbookUtil createSafeSheetName

Introduction

In this page you can find the example usage for org.apache.poi.ss.util WorkbookUtil createSafeSheetName.

Prototype

public static String createSafeSheetName(final String nameProposal, char replaceChar) 

Source Link

Document

Creates a valid sheet name, which is conform to the rules.

Usage

From source file:com.oneis.jsinterface.generate.KGenerateXLS.java

License:Mozilla Public License

@Override
protected void startSheet(String name, int sheetNumber) {
    // Make sure the name is unique (because only one sheet with a particular name is allowed)
    String sheetName = name;//from  w  w  w .j a  v a2  s .c  o m
    int index = 2;
    int safety = 1024;
    while (null != this.workbook.getSheet(sheetName)) {
        sheetName = String.format("%s (%d)", name, index++);
        if (safety-- <= 0) {
            throw new OAPIException("Couldn't make unique name for sheet in generated XLS file");
        }
    }
    this.sheet = this.workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName, '_'));
}

From source file:com.romeikat.datamessie.core.base.util.ExcelSheet.java

License:Open Source License

private String normalizeSheetname(final String sheetname) {
    final String normalizedSheetname = WorkbookUtil.createSafeSheetName(sheetname, '-');
    return normalizedSheetname;
}

From source file:org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter.java

License:Open Source License

private void addOpalTableSheet(XSSFWorkbook workbook, Mica.DatasetVariableContingencyDto dto,
        List<String> terms, List<String> values) {
    String tableName;//from www  . j  a  v  a  2 s  .  co m

    if (dto.hasStudyTable()) {
        tableName = String.format("%s %s", dto.getStudyTable().getTable(), dto.getStudyTable().getDceId());
    } else {
        tableName = String.format("%s %s", dto.getHarmonizationStudyTable().getTable(),
                dto.getHarmonizationStudyTable().getPopulationId());
    }

    XSSFSheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(tableName, '-'));
    writeTable(sheet, dto, tableName, terms, values);
}