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

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

Introduction

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

Prototype

void removeSheetAt(int index);

Source Link

Document

Removes sheet at the given index

Usage

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

License:Apache License

/**
 * @param wb/*from ww w .  j a v  a  2  s . co 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 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.spdx.compare.ExternalReferencesSheet.java

License:Apache License

/**
 * @param wb// www  .  j a v  a2 s .  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 row = sheet.createRow(0);
    sheet.setColumnWidth(NAMESPACE_COL, NAMESPACE_COL_WIDTH * 256);
    sheet.setDefaultColumnStyle(NAMESPACE_COL, defaultStyle);
    Cell extractedHeaderCell = row.createCell(NAMESPACE_COL);
    extractedHeaderCell.setCellStyle(headerStyle);
    extractedHeaderCell.setCellValue(NAMESPACE_TEXT_TITLE);

    sheet.setColumnWidth(CHECKSUM_COL, CHECKSUM_COL_WIDTH * 256);
    sheet.setDefaultColumnStyle(CHECKSUM_COL, defaultStyle);
    Cell checksumHeaderCell = row.createCell(CHECKSUM_COL);
    checksumHeaderCell.setCellStyle(headerStyle);
    checksumHeaderCell.setCellValue(CHECKSUM_TEXT_TITLE);

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

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

License:Apache License

/**
 * @param wb//from   www  .java 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 row = sheet.createRow(0);
    sheet.setColumnWidth(EXTRACTED_TEXT_COL, EXTRACTED_TEXT_WIDTH * 256);
    sheet.setDefaultColumnStyle(EXTRACTED_TEXT_COL, defaultStyle);
    Cell extractedHeaderCell = row.createCell(EXTRACTED_TEXT_COL);
    extractedHeaderCell.setCellStyle(headerStyle);
    extractedHeaderCell.setCellValue(EXTRACTED_TEXT_TITLE);
    for (int i = FIRST_LIC_ID_COL; i < MultiDocumentSpreadsheet.MAX_DOCUMENTS; i++) {
        sheet.setColumnWidth(i, LIC_ID_COL_WIDTH * 256);
        sheet.setDefaultColumnStyle(i, defaultStyle);
        Cell cell = row.createCell(i);
        cell.setCellStyle(headerStyle);
    }
}

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

License:Apache License

/**
 * @param wb/*ww w.j a  v  a  2 s. 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
 *///from  w w w . j a v  a2  s .  c o  m
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);
    }/*w  w w  .ja  va2  s. c  om*/
    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  a2 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  va2  s  .co  m
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);
    }//w w w.  j  av a  2s.  c om
    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   w  ww  .  j a v a2  s  .  c o  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(CURRENT_VERSION);
}