Search in sources :

Example 6 with CellExtra

use of com.alibaba.excel.metadata.CellExtra in project easyexcel by alibaba.

the class XlsxSaxAnalyser method readComments.

private void readComments(ReadSheet readSheet) {
    if (!xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.COMMENT)) {
        return;
    }
    CommentsTable commentsTable = commentsTableMap.get(readSheet.getSheetNo());
    if (commentsTable == null) {
        return;
    }
    Iterator<CellAddress> cellAddresses = commentsTable.getCellAddresses();
    while (cellAddresses.hasNext()) {
        CellAddress cellAddress = cellAddresses.next();
        XSSFComment cellComment = commentsTable.findCellComment(cellAddress);
        CellExtra cellExtra = new CellExtra(CellExtraTypeEnum.COMMENT, cellComment.getString().toString(), cellAddress.getRow(), cellAddress.getColumn());
        xlsxReadContext.readSheetHolder().setCellExtra(cellExtra);
        xlsxReadContext.analysisEventProcessor().extra(xlsxReadContext);
    }
}
Also used : CellAddress(org.apache.poi.ss.util.CellAddress) XSSFComment(org.apache.poi.xssf.usermodel.XSSFComment) CellExtra(com.alibaba.excel.metadata.CellExtra) CommentsTable(org.apache.poi.xssf.model.CommentsTable)

Example 7 with CellExtra

use of com.alibaba.excel.metadata.CellExtra in project easyexcel by alibaba.

the class HyperlinkTagHandler method startElement.

@Override
public void startElement(XlsxReadContext xlsxReadContext, String name, Attributes attributes) {
    String ref = attributes.getValue(ExcelXmlConstants.ATTRIBUTE_REF);
    String location = attributes.getValue(ExcelXmlConstants.ATTRIBUTE_LOCATION);
    if (StringUtils.isEmpty(ref)) {
        return;
    }
    CellExtra cellExtra = new CellExtra(CellExtraTypeEnum.HYPERLINK, location, ref);
    xlsxReadContext.readSheetHolder().setCellExtra(cellExtra);
    xlsxReadContext.analysisEventProcessor().extra(xlsxReadContext);
}
Also used : CellExtra(com.alibaba.excel.metadata.CellExtra)

Aggregations

CellExtra (com.alibaba.excel.metadata.CellExtra)7 ExcelReader (com.alibaba.excel.ExcelReader)1 AnalysisContext (com.alibaba.excel.context.AnalysisContext)1 CellData (com.alibaba.excel.metadata.CellData)1 ReadSheet (com.alibaba.excel.read.metadata.ReadSheet)1 ArrayList (java.util.ArrayList)1 HyperlinkRecord (org.apache.poi.hssf.record.HyperlinkRecord)1 MergeCellsRecord (org.apache.poi.hssf.record.MergeCellsRecord)1 NoteRecord (org.apache.poi.hssf.record.NoteRecord)1 CellAddress (org.apache.poi.ss.util.CellAddress)1 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)1 CommentsTable (org.apache.poi.xssf.model.CommentsTable)1 XSSFComment (org.apache.poi.xssf.usermodel.XSSFComment)1 Test (org.junit.Test)1