Example usage for org.apache.poi.ss.usermodel Workbook getSheetIndex

List of usage examples for org.apache.poi.ss.usermodel Workbook getSheetIndex

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Workbook getSheetIndex.

Prototype

int getSheetIndex(Sheet sheet);

Source Link

Document

Returns the index of the given sheet

Usage

From source file:org.spdx.compare.PackageSheet.java

License:Apache License

/**
 * @param wb//from  ww w.  j a va  2s.  c  o  m
 * @param sheetName
 */
public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);
    }
    Sheet sheet = wb.createSheet(sheetName);
    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle defaultStyle = AbstractSheet.createLeftWrapStyle(wb);
    Row headerRow = sheet.createRow(0);
    sheet.setColumnWidth(FIELD_COL, FIELD_COL_WIDTH * 256);
    sheet.setDefaultColumnStyle(FIELD_COL, defaultStyle);
    Cell fieldCell = headerRow.createCell(FIELD_COL);
    fieldCell.setCellStyle(headerStyle);
    fieldCell.setCellValue(FIELD_HEADER_TEXT);

    sheet.setColumnWidth(EQUALS_COL, EQUALS_COL_WIDTH * 256);
    sheet.setDefaultColumnStyle(EQUALS_COL, defaultStyle);
    Cell equalsCell = headerRow.createCell(EQUALS_COL);
    equalsCell.setCellStyle(headerStyle);
    equalsCell.setCellValue(EQUALS_HEADER_TEXT);

    for (int i = FIRST_DOC_COL; i < MultiDocumentSpreadsheet.MAX_DOCUMENTS + FIRST_DOC_COL; i++) {
        sheet.setColumnWidth(i, COL_WIDTH * 256);
        sheet.setDefaultColumnStyle(i, defaultStyle);
        Cell cell = headerRow.createCell(i);
        cell.setCellStyle(headerStyle);
    }
}

From source file:org.spdx.rdfparser.LicenseSheet.java

License:Apache License

/**
 * Create a blank worksheet NOTE: Replaces / deletes existing sheet by the same name
 *///  w  ww  .  j a  va 2  s. com
public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);
    }
    Sheet sheet = wb.createSheet(sheetName);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        Cell cell = row.createCell(i);
        cell.setCellValue(HEADER_TITLES[i]);
    }
}

From source file:org.spdx.spdxspreadsheet.AnnotationsSheet.java

License:Apache License

public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);//from  w  ww  .  j  a v  a  2 s . c  o  m
    }
    Sheet sheet = wb.createSheet(sheetName);
    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle centerStyle = AbstractSheet.createCenterStyle(wb);
    CellStyle wrapStyle = AbstractSheet.createLeftWrapStyle(wb);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        if (LEFT_WRAP[i]) {
            sheet.setDefaultColumnStyle(i, wrapStyle);
        } else if (CENTER_NOWRAP[i]) {
            sheet.setDefaultColumnStyle(i, centerStyle);
        }
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
}

From source file:org.spdx.spdxspreadsheet.ExternalRefsSheet.java

License:Apache License

/**
 * @param wb/*from   w w w  .j a v  a  2 s. c o  m*/
 * @param externalRefsSheetName
 */
public static void create(Workbook wb, String externalRefsSheetName) {
    int sheetNum = wb.getSheetIndex(externalRefsSheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);
    }
    Sheet sheet = wb.createSheet(externalRefsSheetName);
    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle centerStyle = AbstractSheet.createCenterStyle(wb);
    CellStyle wrapStyle = AbstractSheet.createLeftWrapStyle(wb);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        if (LEFT_WRAP[i]) {
            sheet.setDefaultColumnStyle(i, wrapStyle);
        } else if (CENTER_NOWRAP[i]) {
            sheet.setDefaultColumnStyle(i, centerStyle);
        }
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
}

From source file:org.spdx.spdxspreadsheet.LicenseSheet.java

License:Apache License

/**
 * Create a blank worksheet NOTE: Replaces / deletes existing sheet by the same name
 *//*from w w  w .  j a  v  a2s  .c om*/
public static void create(Workbook wb, String sheetName, String version, String releaseDate) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);
    }
    Sheet sheet = wb.createSheet(sheetName);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        Cell cell = row.createCell(i);
        cell.setCellValue(HEADER_TITLES[i]);
    }
    Row firstDataRow = sheet.createRow(1);
    Cell versionCell = firstDataRow.createCell(COL_VERSION);
    versionCell.setCellValue(version);
    Cell releaseDateCell = firstDataRow.createCell(COL_RELEASE_DATE);
    releaseDateCell.setCellValue(releaseDate);
}

From source file:org.spdx.spdxspreadsheet.NonStandardLicensesSheet.java

License:Apache License

public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);/*from  w w w.j  ava2s.  co  m*/
    }
    Sheet sheet = wb.createSheet(sheetName);
    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle centerStyle = AbstractSheet.createCenterStyle(wb);
    CellStyle wrapStyle = AbstractSheet.createLeftWrapStyle(wb);

    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        if (LEFT_WRAP[i]) {
            sheet.setDefaultColumnStyle(i, wrapStyle);
        } else if (CENTER_NOWRAP[i]) {
            sheet.setDefaultColumnStyle(i, centerStyle);
        }
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
}

From source file:org.spdx.spdxspreadsheet.OriginsSheet.java

License:Apache License

public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);//from   ww  w .  j  a v  a2s  . com
    }

    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle centerStyle = AbstractSheet.createCenterStyle(wb);
    CellStyle wrapStyle = AbstractSheet.createLeftWrapStyle(wb);
    Sheet sheet = wb.createSheet(sheetName);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        if (LEFT_WRAP[i]) {
            sheet.setDefaultColumnStyle(i, wrapStyle);
        } else if (CENTER_NOWRAP[i]) {
            sheet.setDefaultColumnStyle(i, centerStyle);
        }
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
    Row dataRow = sheet.createRow(1);
    Cell ssVersionCell = dataRow.createCell(SPREADSHEET_VERSION_COL);
    ssVersionCell.setCellValue(CURRENT_VERSION);
}

From source file:org.spdx.spdxspreadsheet.OriginsSheetV0d9d4.java

License:Apache License

public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);/*from w  ww  .j  a  v  a 2s. co  m*/
    }

    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle centerStyle = AbstractSheet.createCenterStyle(wb);
    CellStyle wrapStyle = AbstractSheet.createLeftWrapStyle(wb);
    Sheet sheet = wb.createSheet(sheetName);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        if (LEFT_WRAP[i]) {
            sheet.setDefaultColumnStyle(i, wrapStyle);
        } else if (CENTER_NOWRAP[i]) {
            sheet.setDefaultColumnStyle(i, centerStyle);
        }
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
    Row dataRow = sheet.createRow(1);
    Cell ssVersionCell = dataRow.createCell(SPREADSHEET_VERSION_COL);
    ssVersionCell.setCellValue(SPDXSpreadsheet.CURRENT_VERSION);
}

From source file:org.spdx.spdxspreadsheet.PackageInfoSheetV09d2.java

License:Apache License

public static void create(Workbook wb, String sheetName) {
    int sheetNum = wb.getSheetIndex(sheetName);
    if (sheetNum >= 0) {
        wb.removeSheetAt(sheetNum);/*from ww w .  j  av a2s .com*/
    }
    Sheet sheet = wb.createSheet(sheetName);
    CellStyle headerStyle = AbstractSheet.createHeaderStyle(wb);
    CellStyle defaultStyle = AbstractSheet.createLeftWrapStyle(wb);
    Row row = sheet.createRow(0);
    for (int i = 0; i < HEADER_TITLES.length; i++) {
        sheet.setColumnWidth(i, COLUMN_WIDTHS[i] * 256);
        sheet.setDefaultColumnStyle(i, defaultStyle);
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
        cell.setCellValue(HEADER_TITLES[i]);
    }
}

From source file:org.tiefaces.components.websheet.configuration.ConfigurationHandler.java

License:MIT License

/**
 * Copy the each command area to seperated sheet. As it will be used for
 * iteration.// w ww.j  a  v a  2s .c o m
 * 
 * @param sheet
 *            sheet.
 */
private void copyTemplateForTieCommands(final Sheet sheet) {
    // if skip configuration. then return.
    if (parent.isSkipConfiguration()) {
        return;
    }
    Workbook wb = sheet.getWorkbook();
    String copyName = TieConstants.COPY_SHEET_PREFIX + sheet.getSheetName();
    if (wb.getSheet(copyName) == null) {
        Sheet newSheet = wb.cloneSheet(wb.getSheetIndex(sheet));
        int sheetIndex = wb.getSheetIndex(newSheet);
        wb.setSheetName(sheetIndex, copyName);
        wb.setSheetHidden(sheetIndex, Workbook.SHEET_STATE_VERY_HIDDEN);
    }
}