Java 类org.apache.poi.xssf.usermodel.XSSFComment 实例源码

项目:hadoopoffice    文件:MSExcelLowFootprintParser.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    // create empty column, if needed

    CellAddress currentCellAddress = new CellAddress(cellReference);
    for (int i=this.currentColumn;i<currentCellAddress.getColumn();i++) {
        this.spreadSheetCellDAOCurrentRow.add(null);
        this.currentColumn++;
    }
    // add column
    SpreadSheetCellDAO currentDAO = null;
    if (comment!=null) {
        currentDAO = new SpreadSheetCellDAO(formattedValue,comment.getString().getString(), "", cellReference,this.sheetName);
    } else {
        currentDAO = new SpreadSheetCellDAO(formattedValue,"", "", cellReference,this.sheetName);
    }
    this.currentColumn++;
    this.spreadSheetCellDAOCurrentRow.add(currentDAO);
}
项目:OCRaptor    文件:XSSFExcelExtractorDecorator.java   
public void cell(String cellRef, String formattedValue) {
  try {
    xhtml.startElement("td");

    // Main cell contents
    xhtml.characters(formattedValue);

    // Comments
    if (comments != null) {
      XSSFComment comment = comments.findCellComment(cellRef);
      if (comment != null) {
        xhtml.startElement("br");
        xhtml.endElement("br");
        xhtml.characters(comment.getAuthor());
        xhtml.characters(": ");
        xhtml.characters(comment.getString().getString());
      }
    }

    xhtml.endElement("td");
  } catch (SAXException e) {
  }
}
项目:excel-object-mapper    文件:ExcelSheetContentsHandler.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    if (this.currentRow < noOfRowsToSkip)
        return;

    if (formattedValue == null || formattedValue.length() == 0)
        return;

    // Handle the Header Row
    if (this.verifyHeader && this.headerRow == this.currentRow) {
        this.saveHeaderCellValue(cellReference, formattedValue);
    } else {
        this.saveRowCellValue(cellReference, formattedValue);
    }

}
项目:poiji    文件:PoijiHandler.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {

    CellAddress cellAddress = new CellAddress(cellReference);
    int row = cellAddress.getRow();

    if (row + 1 <= options.skip()) {
        return;
    }

    internalCount = row;
    int column = cellAddress.getColumn();
    setFieldValue(formattedValue, type, column);
}
项目:zerocell    文件:CellMethodSpec.java   
public static MethodSpec build(List<ColumnInfoType> columns) {
    final CodeBlock.Builder builder = CodeBlock.builder();
    LoggerFactory.getLogger(ZeroCellAnnotationProcessor.class)
                 .info("Found {} columns in source class", columns.size());
    columns.forEach(column -> {
        String staticFieldName = "COL_" + column.getName();
        String fieldName = column.getFieldName();

        String beanSetterProperty = beanSetterPropertyName(fieldName);

        builder.beginControlFlow("if ($L == column)", staticFieldName)
            .addStatement("assertColumnName($S, formattedValue)", column.getName());

        converterStatementFor(builder, column, beanSetterProperty);

        builder.addStatement("return").endControlFlow();
    });

    return  MethodSpec.methodBuilder("cell")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .addParameter(String.class, "cellReference")
            .addParameter(String.class, "formattedValue", Modifier.FINAL)
            .addParameter(XSSFComment.class, "xssfComment", Modifier.FINAL)
            .addStatement("if (java.util.Objects.isNull(cur)) return")
            .addComment("Gracefully handle missing CellRef here in a similar way as XSSFCell does")
            .beginControlFlow("if(cellReference == null)")
            .addStatement("cellReference = new $T(currentRow, currentCol).formatAsString()", org.apache.poi.ss.util.CellAddress.class)
            .endControlFlow()
            .addStatement("int column = new $T(cellReference).getCol()", org.apache.poi.hssf.util.CellReference.class)
            .addStatement("currentCol = column")
            .addCode(builder.build())
            .build();
}
项目:zerocell    文件:EntityHandler.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment xssfComment) {
    // gracefully handle missing CellRef here in a similar way as XSSFCell does
    if(cellReference == null) {
        cellReference = new CellAddress(currentRow, currentCol).formatAsString();
    }

    int column = new CellReference(cellReference).getCol();
    currentCol = column;

    // We ignore additional cells here since we only care about the cells
    // in the columns array i.e. the defined columns
    if (column > MAXIMUM_COL_INDEX) {
        LOGGER.warn("Invalid Column index found: " + column);
        return;
    }

    ColumnInfo currentColumnInfo = columns[column];

    if (isHeaderRow) {
        if (! currentColumnInfo.getName().equalsIgnoreCase(formattedValue.trim())){
            throw new ZeroCellException(String.format("Expected Column '%s' but found '%s'", currentColumnInfo.getName(), formattedValue));
        }
    }
    // Prevent from trying to write to a null instance
    if (Objects.isNull(cur)) return;
    writeColumnField(cur, formattedValue, currentColumnInfo, currentRow);
}
项目:azeroth    文件:XLSX2CSV.java   
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    if (firstCellOfRow) {
        firstCellOfRow = false;
    } else {
        _resultRowTmp.append(ExcelValidator.FIELD_SPLIT);
    }

    // gracefully handle missing CellRef here in a similar way as
    // XSSFCell does
    if (cellReference == null) {
        cellReference = new CellAddress(currentRow, currentCol).formatAsString();
    }

    // Did we miss any cells?
    int thisCol = (new CellReference(cellReference)).getCol();
    int missedCols = thisCol - currentCol - 1;
    for (int i = 0; i < missedCols; i++) {
        _resultRowTmp.append(ExcelValidator.FIELD_SPLIT);
    }
    currentCol = thisCol;

    // Number or string?
    try {
        Double.parseDouble(formattedValue);
        _resultRowTmp.append(formattedValue);
    } catch (NumberFormatException e) {
        _resultRowTmp.append(formattedValue);
    }
}
项目:UtilsMaven    文件:XLSXReader.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    if (this.isNewRow) {
        this.isNewRow = false;
    }
    // gracefully handle missing CellRef here in a similar way as XSSFCell does
    if (cellReference == null) {
        cellReference = new CellAddress(this.currentRowInSheet, this.currentColInRow).formatAsString();
    }
    // 获取cellReference指向的列数,0-based
    int thisCol = (new CellReference(cellReference)).getCol();
    this.currentColInRow = thisCol;
    if (formattedValue == null || formattedValue.isEmpty()) {
        return;
    }
    if (this.currentRowInSheet == 0) {
        //标题行
        if (this.currentSheetInExcel == 0) {
            //若是第0个Sheet则添加标题,0-based
            this.titles.add(formattedValue);
        }
        return;
    }
    if (this.currentRowInSheet == 1) {
        //列名行
        if (this.currentSheetInExcel == 0) {
            //若是第0个Sheet则添加列名,0-based
            this.columns.add(formattedValue);
        }
        return;
    }
    //数据行
    String key = this.columns.get(this.currentColInRow);
    Object value = this.getValue(formattedValue);
    this.data.put(key, value);
}
项目:morpheus-core    文件:ExcelSource.java   
/**
 * POI calls this with the value parsed from the cell.
 * @param cellReference The cell reference
 * @param formattedValue The value of the cell
 * @param comment a comment
 */
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    this.output.valueParsed(formattedValue);
    int thisCol = (new CellReference(cellReference)).getCol();

    //Fill missing columns
    int missedCols = thisCol - currentCol - 1;
    for (int i=0; i<missedCols; i++) {
        this.output.valueParsed("");
    }
    currentCol = thisCol;
}
项目:jeesuite-libs    文件:XLSX2CSV.java   
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    if (firstCellOfRow) {
        firstCellOfRow = false;
    } else {
        _resultRowTmp.append(ExcelValidator.FIELD_SPLIT);
    }

    // gracefully handle missing CellRef here in a similar way as
    // XSSFCell does
    if (cellReference == null) {
        cellReference = new CellAddress(currentRow, currentCol).formatAsString();
    }

    // Did we miss any cells?
    int thisCol = (new CellReference(cellReference)).getCol();
    int missedCols = thisCol - currentCol - 1;
    for (int i = 0; i < missedCols; i++) {
        _resultRowTmp.append(ExcelValidator.FIELD_SPLIT);
    }
    currentCol = thisCol;

    // Number or string?
    try {
        Double.parseDouble(formattedValue);
        _resultRowTmp.append(formattedValue);
    } catch (NumberFormatException e) {
        _resultRowTmp.append(formattedValue);
    }
}
项目:bingexcel    文件:ExcelXSSFSheetXMLHandler.java   
/**
 * Output an empty-cell comment.
 * 
 * @throws BingSaxReadStopException
 */
private void outputEmptyCellComment(CellReference cellRef)
        throws BingSaxReadStopException {
    String cellRefString = cellRef.formatAsString();
    XSSFComment comment = commentsTable.findCellComment(cellRefString);
    output.cell(rowNum, cellRefString, null, comment);
}
项目:bingexcel    文件:DefaultXSSFSaxHandler.java   
@Override
public void cell(int rowNum, String cellReference,
        String formattedValue, XSSFComment comment)
         {

    if (!Strings.isNullOrEmpty(formattedValue)) {
        int column = nameToColumn(cellReference);
        rowList.add(new CellKV<String>(column, formattedValue));
    }

}
项目:com.opendoorlogistics    文件:XmlParserLoader.java   
@Override
public void cell(String cellReference, String formattedValue,XSSFComment comment) {
    if(currentOutputRow!=-1){
        CellReference ref = new CellReference(cellReference);
        int col = ref.getCol();
        if(col < table.getColumnCount()){
            table.setValueAt(formattedValue, currentOutputRow, col);                    
        }
    }
}
项目:UtilsMaven    文件:XSSFSheetXMLHandlerPlus.java   
/**
 * Output an empty-cell comment.
 */
private void outputEmptyCellComment(CellAddress cellRef) {
    XSSFComment comment = commentsTable.findCellComment(cellRef);
    output.cell(cellRef.formatAsString(), null, comment);
}
项目:Metadata_Utilities    文件:XSSFSpreadsheetMetadataGenerator.java   
private String generateXSSFColumnMetadata(StringBuffer rdfText, boolean firstItem, URI baseRDFURI, int columnIndex, XSSFCell titleCell, XSSFComment summaryCell, XSSFCell valueCell)
{
    if ((titleCell != null) && (titleCell.getCellType() == XSSFCell.CELL_TYPE_STRING))
    {
        String columnId      = UUID.randomUUID().toString();
        String columnLabel   = removeRowNumber(titleCell.getReference());
        String columnName    = titleCell.getStringCellValue();
        String columnComment = null;
        if (titleCell.getCellComment() != null)
            columnComment = titleCell.getCellComment().getString().getString();
        String columnType = null;
        if (valueCell != null)
        {
            if (valueCell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC)
                columnType =  "Number";
            else if (valueCell.getCellType() == XSSFCell.CELL_TYPE_STRING)
                columnType =  "String";
            else if (valueCell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN)
                columnType =  "Boolean";
        }

        if (firstItem)
            firstItem = false;
        else
            rdfText.append('\n');

        rdfText.append("    <x:Column rdf:about=\"");
        rdfText.append(baseRDFURI.resolve('#' + columnId));
        rdfText.append("\">\n");
        rdfText.append("        <x:hasLabel>");
        rdfText.append(escapeXml10(columnLabel));
        rdfText.append("</x:hasLabel>\n");
        rdfText.append("        <x:hasIndex>");
        rdfText.append(columnIndex);
        rdfText.append("</x:hasIndex>\n");
        if (columnType != null)
        {
            rdfText.append("        <x:hasType>");
            rdfText.append(escapeXml10(columnType));
            rdfText.append("</x:hasType>\n");
        }
        if (columnName != null)
        {
            rdfText.append("        <d:hasTitle>");
            rdfText.append(escapeXml10(columnName));
            rdfText.append("</d:hasTitle>\n");
        }
        if (columnComment != null)
        {
            rdfText.append("        <d:hasSummary>");
            rdfText.append(escapeXml10(columnComment));
            rdfText.append("</d:hasSummary>\n");
        }
        rdfText.append("    </x:Column>\n");

        return columnId;
    }
    else
        return null;
}
项目:com.opendoorlogistics    文件:XmlParserLoader.java   
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
    CellReference ref = new CellReference(cellReference);
    currentRow.put((int)ref.getCol(), formattedValue);
}
项目:UtilsMaven    文件:XSSFSheetXMLHandlerPlus.java   
/**
 * A cell, with the given formatted value (may be null),
 * and possibly a comment (may be null), was encountered
 */
public void cell(String cellReference, String formattedValue, XSSFComment comment);
项目:bingexcel    文件:ExcelXSSFSheetXMLHandler.java   
/**
 * A cell, with the given formatted value (may be null), and possibly a
 * comment (may be null), was encountered
 */
public void cell(int rowNum, String cellReference,
        String formattedValue, XSSFComment comment)
        ;