• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CellAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.poi.ss.util.CellAddress的典型用法代码示例。如果您正苦于以下问题:Java CellAddress类的具体用法?Java CellAddress怎么用?Java CellAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CellAddress类属于org.apache.poi.ss.util包,在下文中一共展示了CellAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@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);
}
 
开发者ID:ZuInnoTe,项目名称:hadoopoffice,代码行数:20,代码来源:MSExcelLowFootprintParser.java


示例2: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@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);
}
 
开发者ID:ozlerhakan,项目名称:poiji,代码行数:15,代码来源:PoijiHandler.java


示例3: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@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);
}
 
开发者ID:creditdatamw,项目名称:zerocell,代码行数:29,代码来源:EntityHandler.java


示例4: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
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);
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:30,代码来源:XLSX2CSV.java


示例5: init

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
private void init() {
    if (commentsTable != null) {
        commentCellRefs = new LinkedList<CellAddress>();
        //noinspection deprecation
        for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) {
            commentCellRefs.add(new CellAddress(comment.getRef()));
        }
    }
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:10,代码来源:XSSFSheetXMLHandlerPlus.java


示例6: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@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);
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:37,代码来源:XLSXReader.java


示例7: cell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
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);
	}
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:30,代码来源:XLSX2CSV.java


示例8: getCurrentCell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public PoiCell getCurrentCell() {
    final int currentRow, currentColumn;
    CellAddress cellRef = poiSheet.getActiveCell();
    if (cellRef != null) {
        currentRow = Math.max(getFirstRowNum(), Math.min(getLastRowNum(), cellRef.getRow()));
        currentColumn = Math.max(getFirstColNum(), Math.min(getLastColNum(), cellRef.getColumn()));
    } else {
        currentRow = poiSheet.getTopRow();
        currentColumn = poiSheet.getLeftCol();
    }
    return getCell(currentRow, currentColumn);
}
 
开发者ID:xzel23,项目名称:meja,代码行数:14,代码来源:PoiSheet.java


示例9: outputEmptyCellComment

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
/**
 * Output an empty-cell comment.
 */
private void outputEmptyCellComment(CellAddress cellRef) {
    XSSFComment comment = commentsTable.findCellComment(cellRef);
    output.cell(cellRef.formatAsString(), null, comment);
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:8,代码来源:XSSFSheetXMLHandlerPlus.java


示例10: asTable

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Documentation(
    value = "Insert a table from an Excel .xlsx file.",
    params = {
        @Param(name = "uri", value = "The Excel .xlsx file uri, it can be relative to the template"),
        @Param(name = "sheetName", value = "The sheet name"),
        @Param(name = "topLeftCellAdress", value = "The top left cell address"),
        @Param(name = "bottomRightCellAdress", value = "The bottom right cell address"),
        @Param(name = "languageTag", value = "The language tag for the locale"),
    },
    result = "insert the table",
    examples = {
        @Example(expression = "'excel.xlsx'.asTable('Feuil1', 'C3', 'F7', 'fr-FR')", result = "insert the table from 'excel.xlsx'"),
    }
)
// @formatter:on
public MTable asTable(String uriStr, String sheetName, String topLeftCellAdress, String bottomRightCellAdress,
        String languageTag) throws IOException {
    final MTable res = new MTableImpl();

    final URI xlsxURI = URI.createURI(uriStr, false);
    final URI uri = xlsxURI.resolve(templateURI);

    try (XSSFWorkbook workbook = new XSSFWorkbook(uriConverter.createInputStream(uri));) {
        final FormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook);
        final XSSFSheet sheet = workbook.getSheet(sheetName);
        if (sheet == null) {
            throw new IllegalArgumentException(String.format("The sheet %s doesn't exists in %s.", sheetName, uri));
        } else {
            final Locale locale;
            if (languageTag != null) {
                locale = Locale.forLanguageTag(languageTag);
            } else {
                locale = Locale.getDefault();
            }
            final DataFormatter dataFormatter = new DataFormatter(locale);
            final CellAddress start = new CellAddress(topLeftCellAdress);
            final CellAddress end = new CellAddress(bottomRightCellAdress);
            int rowIndex = start.getRow();
            while (rowIndex <= end.getRow()) {
                final XSSFRow row = sheet.getRow(rowIndex++);
                if (row != null) {
                    final MRow mRow = new MRowImpl();
                    int cellIndex = start.getColumn();
                    while (cellIndex <= end.getColumn()) {
                        final XSSFCell cell = row.getCell(cellIndex++);
                        if (cell != null) {
                            final MStyle style = getStyle(cell);
                            final MElement text = new MTextImpl(dataFormatter.formatCellValue(cell, evaluator),
                                    style);
                            final Color background = getColor(cell.getCellStyle().getFillForegroundColorColor());
                            final MCell mCell = new MCellImpl(text, background);
                            mRow.getCells().add(mCell);
                        } else {
                            mRow.getCells().add(createEmptyCell());
                        }
                    }
                    res.getRows().add(mRow);
                } else {
                    final int length = end.getColumn() - start.getColumn() + 1;
                    res.getRows().add(createEmptyRow(length));
                }
            }

        }
    }

    return res;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:69,代码来源:ExcelServices.java


示例11: write

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
/**
* Add a cell to the current Workbook
*
* @param newDAO cell to add. If it is already existing an exception will be thrown. Note that the sheet name is sanitized using  org.apache.poi.ss.util.WorkbookUtil.createSafeSheetName. The Cell address needs to be in A1 format. Either formula or formattedValue must be not null.
*
*/
@Override
public void write(Object newDAO) throws OfficeWriterException {
	
	SpreadSheetCellDAO sscd = checkSpreadSheetCellDAO(newDAO);
	String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
	Sheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
	if (currentSheet==null) {// create sheet if it does not exist yet
		currentSheet=this.currentWorkbook.createSheet(safeSheetName);
		if (!(safeSheetName.equals(sscd.getSheetName()))) {
			LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
		}
		// create drawing anchor (needed for comments...)
		this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
	}
	// check if cell exist
	CellAddress currentCA = new CellAddress(sscd.getAddress());
	Row currentRow = currentSheet.getRow(currentCA.getRow());
	if (currentRow==null) { // row does not exist? => create it
		currentRow=currentSheet.createRow(currentCA.getRow());
	}
	Cell currentCell = currentRow.getCell(currentCA.getColumn());
	if ((currentCell!=null) && (this.hasTemplate==false)) { // cell already exists and no template loaded ? => throw exception
		throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
	}
	// create cell if no template is loaded or cell not available in template
	if ((this.hasTemplate==false) || (currentCell==null)) {
		currentCell=currentRow.createCell(currentCA.getColumn());		
	}
	// set the values accordingly
	if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
		currentCell.setCellFormula(sscd.getFormula());
		
	} else {	
	// else use formattedValue
		currentCell.setCellValue(sscd.getFormattedValue());
	}
	// set comment
	if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
		/** the following operations are necessary to create comments **/
		/** Define size of the comment window **/
		    ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
    		    anchor.setCol1(currentCell.getColumnIndex());
    		    anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
    		    anchor.setRow1(currentRow.getRowNum());
    		    anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
		/** create comment **/
		    Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
    		    currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
    		    currentComment.setAuthor(this.howc.getCommentAuthor());
		    currentCell.setCellComment(currentComment);

	}
}
 
开发者ID:ZuInnoTe,项目名称:hadoopoffice,代码行数:60,代码来源:MSExcelWriter.java


示例12: write

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public void write(Object newDAO) throws OfficeWriterException {
	SpreadSheetCellDAO sscd = MSExcelWriter.checkSpreadSheetCellDAO(newDAO);
	String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
	SXSSFSheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
	if (currentSheet==null) {// create sheet if it does not exist yet
		currentSheet=this.currentWorkbook.createSheet(safeSheetName);
		if (!(safeSheetName.equals(sscd.getSheetName()))) {
			LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
		}
		// create drawing anchor (needed for comments...)
		this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
	}
	// check if cell exist
	CellAddress currentCA = new CellAddress(sscd.getAddress());
	SXSSFRow currentRow = currentSheet.getRow(currentCA.getRow());
	if (currentRow==null) { // row does not exist? => create it
		currentRow=currentSheet.createRow(currentCA.getRow());
	}
	SXSSFCell currentCell = currentRow.getCell(currentCA.getColumn());
	if ((currentCell!=null)) { // cell already exists and no template loaded ? => throw exception
		throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
	}
	// create cell if no template is loaded or cell not available in template
		currentCell=currentRow.createCell(currentCA.getColumn());		
	// set the values accordingly
	if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
		currentCell.setCellFormula(sscd.getFormula());
		
	} else {	
	// else use formattedValue
		currentCell.setCellValue(sscd.getFormattedValue());
	}
	// set comment
	if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
		/** the following operations are necessary to create comments **/
		/** Define size of the comment window **/
		    ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
    		    anchor.setCol1(currentCell.getColumnIndex());
    		    anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
    		    anchor.setRow1(currentRow.getRowNum());
    		    anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
		/** create comment **/
		   Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
    		    currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
    		    currentComment.setAuthor(this.howc.getCommentAuthor());
		    currentCell.setCellComment(currentComment);

	}
	}
 
开发者ID:ZuInnoTe,项目名称:hadoopoffice,代码行数:51,代码来源:MSExcelLowFootprintWriter.java


示例13: getActiveCell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public CellAddress getActiveCell() {
    throw new UnsupportedOperationException();
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:5,代码来源:StreamingSheet.java


示例14: getCellComment

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public Comment getCellComment(CellAddress ref) {
    throw new UnsupportedOperationException();
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:5,代码来源:StreamingSheet.java


示例15: getCellComments

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public Map<CellAddress, ? extends Comment> getCellComments() {
    throw new UnsupportedOperationException();
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:5,代码来源:StreamingSheet.java


示例16: setActiveCell

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public void setActiveCell(CellAddress address) {
    throw new UnsupportedOperationException();
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:5,代码来源:StreamingSheet.java


示例17: getHyperlink

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public Hyperlink getHyperlink(CellAddress addr) {
    throw new UnsupportedOperationException();
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:5,代码来源:StreamingSheet.java


示例18: getAddress

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
@Override
public CellAddress getAddress() {
    return new CellAddress(this);
}
 
开发者ID:excella-core,项目名称:excella-core,代码行数:5,代码来源:CellClone.java


示例19: getCellComment

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
/**
 * Not supported
 */
@Override
public Comment getCellComment(CellAddress cellAddress) {
  throw new UnsupportedOperationException();
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:8,代码来源:StreamingSheet.java


示例20: getCellComments

import org.apache.poi.ss.util.CellAddress; //导入依赖的package包/类
/**
 * Not supported
 */
@Override
public Map<CellAddress, ? extends Comment> getCellComments() {
  throw new UnsupportedOperationException();
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:8,代码来源:StreamingSheet.java



注:本文中的org.apache.poi.ss.util.CellAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NoFilepatternException类代码示例发布时间:2022-05-22
下一篇:
Java SleepJob类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap