Sha256: 0df4d6388c6c6f2fb1cec6e01037667f3d50401949798d91978772cff80acf7f

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

package org.embulk.parser.poi_excel.bean.util;

import java.text.MessageFormat;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellReference;

public class PoiExcelCellAddress {
	private final CellReference cellReference;

	public PoiExcelCellAddress(String cellAddress) {
		this.cellReference = new CellReference(cellAddress);
	}

	public String getSheetName() {
		return cellReference.getSheetName();
	}

	public Sheet getSheet(Row currentRow) {
		String sheetName = getSheetName();
		if (sheetName != null) {
			Workbook book = currentRow.getSheet().getWorkbook();
			Sheet sheet = book.getSheet(sheetName);
			if (sheet == null) {
				throw new RuntimeException(MessageFormat.format("not found sheet. sheetName={0}", sheetName));
			}
			return sheet;
		} else {
			return currentRow.getSheet();
		}
	}

	public Cell getCell(Row currentRow) {
		Sheet sheet = getSheet(currentRow);

		Row row = sheet.getRow(cellReference.getRow());
		if (row == null) {
			return null;
		}

		return row.getCell(cellReference.getCol());
	}

	public String getString() {
		return cellReference.formatAsString();
	}
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-parser-poi_excel-0.1.11 src/main/java/org/embulk/parser/poi_excel/bean/util/PoiExcelCellAddress.java
embulk-parser-poi_excel-0.1.10 src/main/java/org/embulk/parser/poi_excel/bean/util/PoiExcelCellAddress.java