当前位置: 首页>>代码示例>>Java>>正文


Java Cell.getColumnIndex方法代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Cell.getColumnIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Cell.getColumnIndex方法的具体用法?Java Cell.getColumnIndex怎么用?Java Cell.getColumnIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.usermodel.Cell的用法示例。


在下文中一共展示了Cell.getColumnIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInsertStatementForCell

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
private String getInsertStatementForCell(String userId, Cell cell) {
    String answer = null;
    switch (cell.getColumnIndex()) {
    case 1:
        answer = getInsertStatement(userId, 2237);
        break;
    case 2:
        answer = getInsertStatement(userId, 4352);
        break;
    case 3:
        answer = getInsertStatement(userId, 3657);
        break;
    case 4:
        answer = getInsertStatement(userId, 5565);
        break;
    }
    
    return answer;
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:20,代码来源:AwfulScriptGeneratorRefactoredStep2.java

示例2: addInsertStatementForCell

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
private void addInsertStatementForCell(List<String> lines, String userId, Cell cell) {
    switch (cell.getColumnIndex()) {
    case 1:
        lines.add(getInsertStatement(userId, 2237));
        break;
    case 2:
        lines.add(getInsertStatement(userId, 4352));
        break;
    case 3:
        lines.add(getInsertStatement(userId, 3657));
        break;
    case 4:
        lines.add(getInsertStatement(userId, 5565));
        break;
    }
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:17,代码来源:AwfulScriptGeneratorRefactoredStep1.java

示例3: writeRow

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
private void writeRow(final Row row, final XMLStreamWriter out, final Map<String, String> columns) {
	try {
		int rowIndex = row.getRowNum();
		out.writeStartElement("row");
		final String rowNum = String.valueOf(rowIndex);
		out.writeAttribute("row", rowNum);
		int count = 0;
		Iterator<Cell> cellIterator = row.iterator();
		while (cellIterator.hasNext()) {
			Cell cell = cellIterator.next();
			int columnIndex = cell.getColumnIndex();
			if (this.exportEmptyCells) {
				while (count < columnIndex) {
					this.writeAnyCell(rowIndex, count, null, out, columns);
					count++;
				}
			}
			this.writeCell(cell, out, columns);
			count++;
		}
		out.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:27,代码来源:E2xCmdline.java

示例4: generate

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
@Override
public List<String> generate(Sheet sheet) {
    List<String> lines = new ArrayList<>();
    for (Row row : sheet) {
        Cell firstCell = row.getCell(0);
        if (firstCell != null) {
            String userId = firstCell.getStringCellValue();
            if (".".equals(userId.substring(1, 2))) {
                for (Cell cell : row) {
                    if (cell.getColumnIndex() == 0) {
                        continue;
                    }

                    if ("X".equals(cell.getStringCellValue())) {
                        switch (cell.getColumnIndex()) {
                        case 1:
                            lines.add(getInsertStatement(userId, 2237));
                            break;
                        case 2:
                            lines.add(getInsertStatement(userId, 4352));
                            break;
                        case 3:
                            lines.add(getInsertStatement(userId, 3657));
                            break;
                        case 4:
                            lines.add(getInsertStatement(userId, 5565));
                            break;
                        }
                    }
                }
            }
        }
    }

    return lines;
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:37,代码来源:AwfulScriptGenerator.java

示例5: addInsertStatementsForRow

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
private void addInsertStatementsForRow(List<String> lines, Row row, String userId) {
    for (Cell cell : row) {
        if (cell.getColumnIndex() == 0) {
            continue;
        }

        if (hasAuthority(cell)) {
            addInsertStatementForCell(lines, userId, cell);
        }
    }
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:12,代码来源:AwfulScriptGeneratorRefactoredStep1.java

示例6: getInsertStatementsForRow

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
private List<String> getInsertStatementsForRow(Row row, String userId) {
    List<String> lines = new ArrayList<>();
    for (Cell cell : row) {
        if (cell.getColumnIndex() == 0) {
            continue;
        }

        if (hasAuthority(cell)) {
            lines.add(getInsertStatementForCell(userId, cell));
        }
    }
    return lines;
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:14,代码来源:AwfulScriptGeneratorRefactoredStep2.java

示例7: writeFirstRow

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Gets field names from column titles and writes the titles element with
 * columns out
 *
 * @param row
 *            the row to parse
 * @param columns
 *            the map with the values
 */
private void writeFirstRow(Row row, final XMLStreamWriter out, final Map<String, String> columns) {
	Iterator<Cell> cellIterator = row.iterator();
	int count = 0;
	try {
		out.writeStartElement("columns");
		while (cellIterator.hasNext()) {
			Cell cell = cellIterator.next();
			// Generate empty headers if required
			if (this.exportEmptyCells) {
				int columnIndex = cell.getColumnIndex();
				while (count < columnIndex) {
					String noLabel = "NoLabel" + String.valueOf(count);
					columns.put(String.valueOf(count), noLabel);
					out.writeStartElement("column");
					out.writeAttribute("empty", "true");
					out.writeAttribute("col", String.valueOf(count));
					out.writeAttribute("title", noLabel);
					out.writeEndElement();
					count++;
				}
			}

			final String cellValue = this.getCellValue(cell, count);
			if (cellValue != null) {
				columns.put(String.valueOf(cell.getColumnIndex()), cellValue);
				out.writeStartElement("column");
				out.writeAttribute("title", cellValue);
				out.writeAttribute("col", String.valueOf(cell.getColumnIndex()));
				out.writeEndElement();
			}
			count++;
		}
		out.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:47,代码来源:E2xCmdline.java

示例8: loadDataBlock

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Parses the test case data (the data between TEST_CASE_START and TEST_CASE_END commented cells) from the
 * excel spreadsheet and loads it into a two-dimensional Object[][] array - workingObjectArray
 */
private void loadDataBlock(
                            Method method ) throws DataProviderException {

    Sheet sheet = excelFileWorkbook.getSheet(this.sheetName);
    if (sheet == null) {
        throw new DataProviderException(UNABLE_TO_LOAD_SHEETS + this.sheetName);
    }

    //Get the starting cell coordinates
    Cell startingCell = getStartingCell(sheet);
    int startCol = startingCell.getColumnIndex();
    int startRow = startingCell.getRowIndex();

    //Get the ending cell coordinates
    Cell endingCell = getEndingCell(sheet);
    int endCol = endingCell.getColumnIndex();
    int endRow = endingCell.getRowIndex();

    if (method.getParameterTypes().length != (endCol - startCol) + 1) {
        throw new DataProviderException(" Expected " + method.getParameterTypes().length
                                        + " parameters in the test method while the table has "
                                        + ( (endCol - startCol) + 1));
    }
    // If the data table is to be returned as a Cartesian product of the rows (the not empty cells)
    if (isMultipliable) {
        makeCartesianProductTable(startCol, startRow, endCol, endRow, sheet, method);
    } else {
        // Initialize the object array
        int columns = endCol - startCol + 1;
        int rows = endRow - startRow + 1;
        this.log.debug(CREATING_DATA_BLOCK + columns + "/" + rows);
        this.workingObjectArray = new Object[rows][columns];

        //Fill the object array iterating the sheet column by column
        for (int col = startCol, parameterIndex = 0; col <= endCol; col++, parameterIndex++) {

            //Get the type of the method parameter at the current position
            Class<?> parameterType = getParameterTypeAt(method, parameterIndex);

            //Iterate over the current column to load the cells according to the parameter type
            for (int row = startRow; row <= endRow; row++) {
                Row rowValue = sheet.getRow(row);
                if (rowValue != null) {
                    Cell currentCell = rowValue.getCell(col, Row.CREATE_NULL_AS_BLANK);
                    this.workingObjectArray[row - startRow][parameterIndex] = parseCellContents(currentCell,
                                                                                                parameterType);
                }
            }
        }
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:56,代码来源:ExcelParser.java

示例9: parseHeaderRow

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Method parses the header row of the sheet to extract the languages.
 * 
 * @param sheet the Excel sheet to process
 * @return a Map with column number to language mapping.
 */
private Map<Integer, Locale> parseHeaderRow(Sheet sheet) throws I18nException
{

	if (sheet == null || sheet.getRow(this.languageHeaderRow) == null)
	{
		return null;
	}
	Map<Integer, Locale> langKeys = new HashMap<Integer, Locale>();
	Map<Integer, String> invalidKeys = new HashMap<Integer, String>();
	for (Iterator<?> cit = sheet.getRow(this.languageHeaderRow).cellIterator(); cit.hasNext();)
	{
		Cell cell = (Cell) cit.next();
		if (cell.getColumnIndex() >= this.firstLanguageColumn)
		{
			String value = cell.getRichStringCellValue().getString();
			try
			{
				Locale locale = LocaleUtils.toLocale(value);
				if (locale != null)
				{
					langKeys.put(cell.getColumnIndex(), locale);
				}
				else
				{
					invalidKeys.put(cell.getColumnIndex(), value);
				}
			}
			catch (IllegalArgumentException e)
			{
				invalidKeys.put(cell.getColumnIndex(), value);
			}
		}
	}
	if (!invalidKeys.isEmpty())
	{
		throw new I18nException("Invalid column header in this sheet:" + invalidKeys.toString());
	}
	if (langKeys.isEmpty())
	{
		return null;
	}
	LOG.info("languages found:  [" + langKeys.values() + "]");
	return langKeys;
}
 
开发者ID:namics,项目名称:spring-i18n-support,代码行数:51,代码来源:ExcelReader.java

示例10: writeCell

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Writes out an XML cell based on an Excel cell's actual value
 * 
 * @param cell
 *            The Excel cell
 * @param out
 *            the output stream
 * @param columns
 *            the Map with column titles
 */
private void writeCell(final Cell cell, final XMLStreamWriter out, final Map<String, String> columns) {

	String cellValue = this.getCellValue(cell);
	int col = cell.getColumnIndex();
	int row = cell.getRowIndex();
	this.writeAnyCell(row, col, cellValue, out, columns);
}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:18,代码来源:E2xCmdline.java


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