當前位置: 首頁>>代碼示例>>Java>>正文


Java CellReference.convertNumToColString方法代碼示例

本文整理匯總了Java中org.apache.poi.ss.util.CellReference.convertNumToColString方法的典型用法代碼示例。如果您正苦於以下問題:Java CellReference.convertNumToColString方法的具體用法?Java CellReference.convertNumToColString怎麽用?Java CellReference.convertNumToColString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.ss.util.CellReference的用法示例。


在下文中一共展示了CellReference.convertNumToColString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatCellStatus

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
protected void formatCellStatus(Sheet sheet, Cell cell) {
	cell.setCellStyle(styles.get("status"));
	SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
	ConditionalFormattingRule ruleGreen = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "1");
	PatternFormatting fill1 = ruleGreen.createPatternFormatting();
	fill1.setFillBackgroundColor(IndexedColors.GREEN.index);
	fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleRed = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "0");
	PatternFormatting fill2 = ruleRed.createPatternFormatting();
	fill2.setFillBackgroundColor(IndexedColors.RED.index);
	fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleOrange = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "2");
	PatternFormatting fill3 = ruleOrange.createPatternFormatting();
	fill3.setFillBackgroundColor(IndexedColors.ORANGE.index);
	fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	String name = CellReference.convertNumToColString(cell.getColumnIndex());
	String location = "$" + name + "$" + cell.getRowIndex() + ":$" + name + "$" + (cell.getRowIndex() + 1);

	CellRangeAddress[] regions = { CellRangeAddress.valueOf(location) };
	ConditionalFormattingRule[] cfRules = new ConditionalFormattingRule[] { ruleGreen, ruleRed, ruleOrange };
	sheetCF.addConditionalFormatting(regions, cfRules);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:26,代碼來源:XLTest.java

示例2: getKyokaAvgFormula

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public String getKyokaAvgFormula(Point point) {
    
    // レコード名が平均のときのみ數式を出力する
    if(!name.equals("平均")) {
        return null;
    }
    
    // レコードのサイズ(平均用のレコード行を覗いた値)
    final int dataSize = parent.getRecords().size() -1;
    
    // 列名
    final String colAlpha = CellReference.convertNumToColString(point.x);
    
    // 平均値の開始/終了の行番號
    final int startRowNumber = point.y - dataSize+1;
    final int endRowNumber = point.y;
    
    return String.format("AVERAGE(%s%d:%s%d)", colAlpha, startRowNumber, colAlpha, endRowNumber);
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:20,代碼來源:AnnoFormulaTest.java

示例3: toColNamesMap

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private Map<String, Integer> toColNamesMap(Row headerRow)
{
	if (headerRow == null) return null;

	Map<String, Integer> columnIdx = new LinkedCaseInsensitiveMap<>();
	int i = 0;
	for (Iterator<Cell> it = headerRow.cellIterator(); it.hasNext(); )
	{
		try
		{
			String header = AbstractCellProcessor.processCell(ExcelUtils.toValue(it.next()), true, cellProcessors);
			if (null != header) columnIdx.put(header, i++);
		}
		catch (final IllegalStateException ex)
		{
			final int row = headerRow.getRowNum();
			final String column = CellReference.convertNumToColString(i);
			throw new IllegalStateException("Invalid value at [" + sheet.getSheetName() + "] " + column + row + 1,
					ex);
		}
	}
	return columnIdx;
}
 
開發者ID:molgenis,項目名稱:molgenis,代碼行數:24,代碼來源:ExcelRepository.java

示例4: evaluateFormulaCell

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private static int evaluateFormulaCell(Cell cell, FormulaEvaluator evaluator) {
	int typ = -1;
	try {
		typ = evaluator.evaluateFormulaCell(cell);
	} catch (RuntimeException e) {
		String cellRef = CellReference.convertNumToColString(cell.getColumnIndex())+(cell.getRowIndex()+1);
		String errMsg = "Error while evaluating cell " + cellRef + " from sheet " + cell.getSheet().getSheetName() + ": " + e.getMessage();
		throw new RuntimeException(errMsg, e);
	}
	return typ;
}
 
開發者ID:denkbar,項目名稱:step,代碼行數:12,代碼來源:ExcelFunctions.java

示例5: getCountFormula

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public String getCountFormula(final Point address) {
    
    final String columnAlpha = CellReference.convertNumToColString(address.x);
    if(!columnAlpha.equals("G")) {
        return null;
    }
    
    final int rowIndex = address.y + 1;
    
    String formula =  String.format("COUNTIF(D%d:F%d, \"出席\")", rowIndex, rowIndex);
    return formula;
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:13,代碼來源:AnnoHorizontalRecordsTest.java

示例6: getCountFormula

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public String getCountFormula(final Point address) {
    
    final int rowNumber = address.y + 1;
    if(rowNumber != 16) {
        return null;
    }
    final String columnAlpha = CellReference.convertNumToColString(address.x);
    
    
    String formula =  String.format("COUNTIF(%s13:%s15, \"出席\")", columnAlpha, columnAlpha);
    return formula;
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:13,代碼來源:AnnoVerticalRecordsTest.java

示例7: createDataFromOpenOfficeSpreadsheet

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public List<Object[]> createDataFromOpenOfficeSpreadsheet(
		SpreadSheet spreadSheet) {
	HashMap<String, String> columns = new HashMap<>();
	List<Object[]> result = new LinkedList<>();
	Sheet sheet = (sheetName.isEmpty()) ? spreadSheet.getFirstSheet()
			: spreadSheet.getSheet(sheetName);
	if (debug) {
		System.err
				.println("Reading Open Office Spreadsheet : " + sheet.getName());
	}
	int columnCount = sheet.getColumnCount();
	int rowCount = sheet.getRowCount();
	@SuppressWarnings("rawtypes")
	Cell cell = null;
	for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
		String columnHeader = sheet.getImmutableCellAt(columnIndex, 0).getValue()
				.toString();
		if (StringUtils.isBlank(columnHeader)) {
			break;
		}
		String columnName = CellReference.convertNumToColString(columnIndex);
		columns.put(columnName, columnHeader);
		if (debug) {
			System.err
					.println(columnIndex + " = " + columnName + " " + columnHeader);
		}
	}
	// NOTE: often there may be no ranges defined
	Set<String> rangeeNames = sheet.getRangesNames();
	Iterator<String> rangeNamesIterator = rangeeNames.iterator();

	while (rangeNamesIterator.hasNext()) {
		if (debug) {
			System.err.println("Range = " + rangeNamesIterator.next());
		}
	}
	// isCellBlank has protected access in Table
	for (int rowIndex = 1; rowIndex < rowCount && StringUtils.isNotBlank(sheet
			.getImmutableCellAt(0, rowIndex).getValue().toString()); rowIndex++) {
		List<Object> resultRow = new LinkedList<>();
		for (int columnIndex = 0; columnIndex < columnCount && StringUtils
				.isNotBlank(sheet.getImmutableCellAt(columnIndex, rowIndex).getValue()
						.toString()); columnIndex++) {
			cell = sheet.getImmutableCellAt(columnIndex, rowIndex);
			// TODO: column selection
			/*
			String cellName = CellReference.convertNumToColString(columnIndex);
			if (columns.get(cellName).equals("COUNT")) {
				assertEquals(cell.getValueType(), ODValueType.FLOAT);
				expected_count = Double.valueOf(cell.getValue().toString());
			}
			if (columns.get(cellName).equals("SEARCH")) {
				assertEquals(cell.getValueType(), ODValueType.STRING);
				search_keyword = cell.getTextValue();
			}
			if (columns.get(cellName).equals("ID")) {
				System.err.println("Column: " + columns.get(cellName));
				assertEquals(cell.getValueType(), ODValueType.FLOAT);
				id = Integer.decode(cell.getValue().toString());
			}
			*/
			@SuppressWarnings("unchecked")
			Object cellValue = safeOOCellValue(cell);
			if (debug) {
				System.err.println("Cell Value: " + cellValue.toString() + " "
						+ cellValue.getClass());
			}
			resultRow.add(cellValue);
		}
		result.add(resultRow.toArray());
	}
	return result;
}
 
開發者ID:sergueik,項目名稱:junit-dataproviders,代碼行數:74,代碼來源:Utils.java

示例8: getCellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
@Override
public String getCellAddress() {
    return CellReference.convertNumToColString(cell.getColumnIndex()) + String.valueOf(cell.getRowIndex()+1);
}
 
開發者ID:mygreen,項目名稱:excel-cellformatter,代碼行數:5,代碼來源:POICell.java

示例9: visitColumnNumber

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
@Override
public void visitColumnNumber(Column column, int index1) {
	String value = CellReference.convertNumToColString(index1 - 1);
	pageBuilder.setString(column, value);
}
 
開發者ID:hishidama,項目名稱:embulk-parser-poi_excel,代碼行數:6,代碼來源:StringCellVisitor.java

示例10: getCellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static String getCellAddress(int row, int col) {
    return CellReference.convertNumToColString(col) + (row+1);
}
 
開發者ID:jbrundege,項目名稱:taro,代碼行數:4,代碼來源:SpreadsheetTab.java

示例11: getCellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static String getCellAddress(int col, int row) {
    return CellReference.convertNumToColString(col) + (row+1);
}
 
開發者ID:jbrundege,項目名稱:taro,代碼行數:4,代碼來源:SpreadsheetReader.java

示例12: getAverageFormula

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public String getAverageFormula(final Point address) {
    
    final String columnAlpha = CellReference.convertNumToColString(address.x);
    
    final int startRow = address.y + 1- parent.gradeRecrods.size() + 1;
    final int endRow = address.y + 1 - 1;
    
    String formula =  String.format("AVERAGE(%s%d:%s%d)", columnAlpha, startRow, columnAlpha, endRow);
    return formula;
    
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:12,代碼來源:AnnoHorizontalRecordsTest.java

示例13: getAverageFormula

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public String getAverageFormula(final Point address) {
    
    final int rowNumber = address.y + 1;
    
    final String startColumnAlpha = CellReference.convertNumToColString(address.x + 1 - parent.gradeRecrods.size());
    final String endColumnAlpha = CellReference.convertNumToColString(address.x - 1);
    
    String formula =  String.format("AVERAGE(%s%d:%s%d)", startColumnAlpha, rowNumber, endColumnAlpha, rowNumber);
    return formula;
    
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:12,代碼來源:AnnoVerticalRecordsTest.java

示例14: formatCellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * 座標をExcelのアドレス形式'A1'などに変換する
 * @param rowIndex 行インデックス
 * @param colIndex 列インデックス
 * @return
 */
public static String formatCellAddress(final int rowIndex, final int colIndex) {
    return CellReference.convertNumToColString(colIndex) + String.valueOf(rowIndex+1);
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:10,代碼來源:POIUtils.java

示例15: formatAsString

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * セルのアドレスを取得する。
 * @return 'A1'の形式で、セルノアドレスを文字列として表現する。
 */
public String formatAsString() {
    return CellReference.convertNumToColString(this.column) + (this.row + 1);
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:8,代碼來源:CellAddress.java


注:本文中的org.apache.poi.ss.util.CellReference.convertNumToColString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。