當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。