Example usage for org.apache.poi.xssf.usermodel XSSFRow removeCell

List of usage examples for org.apache.poi.xssf.usermodel XSSFRow removeCell

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFRow removeCell.

Prototype

@Override
public void removeCell(Cell cell) 

Source Link

Document

Remove the Cell from this row.

Usage

From source file:uk.ac.manchester.cs.owl.semspreadsheets.model.xssf.impl.WorkbookXSSFImpl.java

License:Open Source License

public void visit(SetCellValue setCellValue) {
    XSSFSheet xssfSheet = workbook.getSheet(setCellValue.getSheet().getName());
    XSSFRow xssfRow = xssfSheet.getRow(setCellValue.getRow());
    if (xssfRow == null && setCellValue.getNewValue() != null) {
        xssfRow = xssfSheet.createRow(setCellValue.getRow());
    }//from w  w w .  j  a  va  2 s . co  m
    XSSFCell xssfCell = xssfRow.getCell(setCellValue.getCol());
    if (xssfCell == null && setCellValue.getNewValue() != null) {
        xssfCell = xssfRow.createCell(setCellValue.getCol());
    }
    if (xssfCell != null) {
        if (setCellValue.getNewValue() != null) {
            xssfCell.setCellValue(new XSSFRichTextString(setCellValue.getNewValue().toString()));
        } else {
            xssfRow.removeCell(xssfCell);
        }
    }
}