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

Java Name类代码示例

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

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



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

示例1: createName

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
protected void createName(HandlerState state, String bookmark, int row1, int col1, int row2, int col2 ) {
	CellReference crFirst = new CellReference( state.currentSheet.getSheetName(), row1, col1, true, true );
	CellReference crLast = new CellReference( row2, col2, true, true );
	String formula = crFirst.formatAsString() + ":" + crLast.formatAsString();

	Name name = state.currentSheet.getWorkbook().getName(bookmark);
	if( name == null ) {
		name = state.currentSheet.getWorkbook().createName();
		name.setNameName( bookmark ); 
		name.setRefersToFormula( formula );
	} else {
		String existingFormula = name.getRefersToFormula();
		try {
			name.setRefersToFormula(existingFormula + "," + formula);
		} catch( FormulaParseException ex ) {
			log.warn( 0, "Unable to add \"" + formula + "\" to name (\"" + bookmark + "\") with existing formula: " + existingFormula, ex );
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:20,代码来源:AbstractHandler.java


示例2: makeNames

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
private Map<Integer, PoiProxyName> makeNames(Workbook wb, EvaluationWorkbook ewb) {
    Map<Integer, PoiProxyName> names = new HashMap<>();

    for (int nIdx = 0; nIdx < wb.getNumberOfNames(); nIdx++) {
        Name wbName = wb.getNameAt(nIdx);

        Ptg[] ptgs;
        String refersToFormula;
        if (!wbName.isFunctionName() && wbName.getRefersToFormula() != null) { //NOPMD
            refersToFormula = wbName.getRefersToFormula();
            ptgs = FormulaParser.parse(refersToFormula, (FormulaParsingWorkbook) ewb, FormulaType.NAMEDRANGE, 0 /*TODO: sheet index*/);
        } else {
            ptgs = null;
            refersToFormula = null;
        }

        names.put(nIdx, new PoiProxyName(wbName.getNameName(), wbName.isFunctionName(), refersToFormula != null, ptgs, wbName.isFunctionName(), nIdx));
    }

    return names;
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:22,代码来源:PoiWorkbookConverters.java


示例3: validateNamedRange

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
private void validateNamedRange( Workbook workbook, int index, String name, int sheetIndex, int row1, int col1, int row2, int col2 ) {

		Name namedRange = workbook.getNameAt(index);
        assertEquals( name,namedRange.getNameName() );
        assertEquals( sheetIndex, namedRange.getSheetIndex() );
        
        AreaReference ref = new AreaReference( namedRange.getRefersToFormula() );
        
        if( ( row1 == row2 ) && ( col1 == col2 ) ) {
        	assertTrue( ref.isSingleCell() );
        	assertEquals( row1, ref.getFirstCell().getRow() );
        	assertEquals( col1, ref.getFirstCell().getCol() );
        } else {
        	assertTrue( AreaReference.isContiguous( namedRange.getRefersToFormula() ) );
	        assertEquals( row1, Math.min( ref.getFirstCell().getRow(), ref.getLastCell().getRow() ) );
	        assertEquals( col1, Math.min( ref.getFirstCell().getCol(), ref.getLastCell().getCol() ) );
	        assertEquals( row2, Math.max( ref.getFirstCell().getRow(), ref.getLastCell().getRow() ) );
	        assertEquals( col2, Math.max( ref.getFirstCell().getCol(), ref.getLastCell().getCol() ) );
        }
	}
 
开发者ID:eclipse,项目名称:birt,代码行数:21,代码来源:HyperlinksTest.java


示例4: defineName

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
/**
 * 指定した範囲の名前を登録する。
 * <p>POI-3.7以上が必要。
 * <p>指定した名前が既に存在する場合は、新しい範囲に書き換える。
 * @param sheet シート
 * @param name 名前
 * @param startPosition 設定するセルの開始位置
 * @param endPosition 設定するセルの終了位置
 * @return
 */
public static Name defineName(final Sheet sheet, final String name,
        final Point startPosition, final Point endPosition) {
    
    ArgUtils.notNull(sheet, "sheet");
    ArgUtils.notEmpty(name, "name");
    ArgUtils.notNull(startPosition, "startPosition");
    ArgUtils.notNull(endPosition, "endPosition");
    
    final Workbook workbook = sheet.getWorkbook();
    Name nameObj = workbook.getName(name);
    if(nameObj == null) {
        nameObj = workbook.createName();
        nameObj.setNameName(name);
    }
    
    final AreaReference areaRef = buildNameArea(sheet.getSheetName(), startPosition, endPosition);
    nameObj.setRefersToFormula(areaRef.formatAsString());
    
    return nameObj;
    
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:32,代码来源:POIUtils.java


示例5: run

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
@Override
public void run() {
    synchronized(lock) {
        try {
            names = new ArrayList<String>();
            Workbook wb = WorkbookFactory.create(file);
            for(Name name : ExcelUtil.getReferenceNames(wb))
                names.add(name.getNameName());
        } catch (Exception ex2) {
            this.ex = ex2;
        }
    }
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:14,代码来源:ExcelNameReader.java


示例6: getWorkbookNames

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public static Map<String, String> getWorkbookNames(Workbook workbook) {
    Map<String, String> result = new HashMap<>(workbook.getNumberOfNames());
    for (int i = 0 ; i < workbook.getNumberOfNames() ; i++) {
        Name name = workbook.getNameAt(i);
        result.put(name.getNameName(), name.getRefersToFormula());
    }
    return result;
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:9,代码来源:SpreadsheetAuditor.java


示例7: isOverlapped

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public boolean isOverlapped(Name name) {
	String ref = name.getRefersToFormula();
	int idx = ref.indexOf('!');
	if (idx != -1) {
		ref = ref.substring(idx + 1);
	}
	AreaReference area = new AreaReference(ref);
	CellReference topLeft = area.getFirstCell();
	CellReference bottomRight = area.getLastCell();
	CellRangeAddress cra = new CellRangeAddress(
		topLeft.getRow(), bottomRight.getRow(), 
		topLeft.getCol(), bottomRight.getCol()
	);
	return isOverlapped(cra);
}
 
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:16,代码来源:InputRule.java


示例8: getListCellRendererComponent

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if(value instanceof Name)
        setText(((Name)value).getNameName());
    return this;
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:8,代码来源:ReferenceComboRenderer.java


示例9: getCellReference

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public static CellReference getCellReference(Workbook wb, String ref) {
    Name name = wb.getName(ref);
    if(name != null)
        ref = name.getRefersToFormula();
    
    if(ref.indexOf(':') > 0) {
        AreaReference aRef = new AreaReference(ref);
        return aRef.getFirstCell();
    } else {
        return new CellReference(ref);
    }
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:13,代码来源:ExcelUtil.java


示例10: getReferenceNames

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public static List<Name> getReferenceNames(Workbook wb) {
    int size = wb.getNumberOfNames();
    List<Name> result = new ArrayList<Name>(size);
    
    for(int i = 0; i < size; i++) {
        Name name = wb.getNameAt(i);
        if(isReferenceName(wb, name))
            result.add(name);
    }
    
    return result;
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:13,代码来源:ExcelUtil.java


示例11: toDataModel

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
/**
 * For given {@link Workbook} does convert everything to new {@link DataModel} structure.
 * Does copy all supported fields (for supported fields see {@link DataModel} class.
 */
static IDataModel toDataModel(final Workbook workbook) {
    if (workbook == null) { return null; }
    
    //add custom functions information
    workbook.addToolPack(getUdfFinder());
    
    Sheet s = workbook.getSheetAt(0); //TODO: only one sheet is supported
    if (s == null) { return null; }
    
    IDataModel dm = new DataModel(s.getSheetName());
    
    for (int i = s.getFirstRowNum(); i <= s.getLastRowNum(); i++) {
        Row r = s.getRow(i);
        if (r == null) { continue; }
        
        DmRow row = new DmRow(i);
        dm.setRow(i, row);
        
        for (int j = r.getFirstCellNum(); j < r.getLastCellNum(); j++) {
            Cell c = r.getCell(j);
            if (c == null) { continue; }
            
            DmCell cell = new DmCell();
            row.setCell(j, cell);
            
            cell.setAddress(new CellAddress(dm.getDataModelId(), A1Address.fromRowColumn(i, j)));
            cell.setContent(ConverterUtils.resolveCellValue(c));
        }
    }

    EvaluationWorkbook evaluationWbook = ConverterUtils.newEvaluationWorkbook(workbook);

    for (int nIdx = 0; nIdx < workbook.getNumberOfNames(); nIdx++) {
        Name name = workbook.getNameAt(nIdx);

        String reference = name.getRefersToFormula();
        if (reference == null) { continue; }

        if (A1Address.isAddress(removeSheetFromNameRef(reference))) {
            dm.setNamedAddress(name.getNameName(), A1Address.fromA1Address(removeSheetFromNameRef(reference)));
        } else if (isFormula(reference, evaluationWbook)) {
            dm.setNamedValue(name.getNameName(), new CellValue(FORMULA_PREFIX + reference));
        } else {
            dm.setNamedValue(name.getNameName(), CellValue.from(reference));
        }
    }

    return dm;
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:54,代码来源:DataModelConverters.java


示例12: getName

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


示例13: getNames

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


示例14: getAllNames

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


示例15: getNameAt

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


示例16: createName

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


示例17: removeName

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


示例18: TempName

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public TempName(Name name, AreaReference area, int mrCount) {
	this.name = name;
	this.area = area;
	this.relatedMergedRegion = new BitSet(mrCount);
}
 
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:6,代码来源:ExcelUtils.java


示例19: NamedCellInfo

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public NamedCellInfo(Name name, List<CellReference> list) {
	this.name = name;
	this.list = list;
}
 
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:5,代码来源:NamedCellInfo.java


示例20: isReferenceName

import org.apache.poi.ss.usermodel.Name; //导入依赖的package包/类
public static boolean isReferenceName(Workbook wb, Name name) {
    return !name.isFunctionName()
            && !name.isDeleted()
            && wb.getSheetIndex(name.getNameName()) < 0;
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:6,代码来源:ExcelUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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