本文整理匯總了Java中org.apache.poi.ss.util.CellReference.getRow方法的典型用法代碼示例。如果您正苦於以下問題:Java CellReference.getRow方法的具體用法?Java CellReference.getRow怎麽用?Java CellReference.getRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.util.CellReference
的用法示例。
在下文中一共展示了CellReference.getRow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEmptyRow
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static int getEmptyRow(Workbook wb, int sheetIndex, String cellRef) {
final Sheet sheet = wb.getSheetAt(sheetIndex);
final CellReference cellReference = new CellReference(cellRef); // һ����A1
boolean flag = false;
for (int i = cellReference.getRow(); i <= sheet.getLastRowNum();) {
final Row r = sheet.getRow(i);
if (r == null) {
// ����ǿ��У���û���κ����ݡ���ʽ����ֱ�Ӱ������µ����������ƶ�
sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1);
continue;
}
flag = false;
for (final Cell c : r) {
if (c.getCellType() != Cell.CELL_TYPE_BLANK) {
flag = true;
break;
}
}
if (flag) {
i++;
continue;
} else {// ����ǿհ��У�������û�����ݣ�������һ����ʽ��
if (i == sheet.getLastRowNum())// ����������һ�У�ֱ�ӽ���һ��remove��
sheet.removeRow(r);
else// �����û�����һ�У�������������һ��
sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1);
}
}
return sheet.getLastRowNum() + 1;
}
示例2: fromA1Address
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static A1Address fromA1Address(String a1address) {
//check in pool
A1Address address = A1AddressPool.get(a1address);
if (address != null) { return address; }
//check if range
if (isRange(a1address)) { return new A1RangeAddress(a1address); }
//create
A1Address a = new A1Address();
a.address = a1address;
CellReference cr = new CellReference(a.address);
a.row = cr.getRow();
a.column = cr.getCol();
return a;
}
示例3: isReferenceValid
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public boolean isReferenceValid(CellReference ref) {
if(ref == null)
return false;
String sheet = ref.getSheetName();
if(sheet == null || sheet.length()==0 || !sheets.contains(sheet))
return false;
if(ref.getCol() >= getMaxCol())
return false;
if(ref.getRow() >= getMaxRow())
return false;
return true;
}
示例4: getXY
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public final static int[] getXY(String xy) {
xy = xy.trim();
if (StringUtils.isEmpty(xy)) {
return new int[] { -1, -1 };
}
if (!StringUtils.isAlphanumeric(xy)) {
return null;
}
CellReference ref = new CellReference(xy);
return new int[] { ref.getRow() < 0 ? -1 : ref.getRow(), ref.getCol() < 0 ? -1 : ref.getCol() };
}
示例5: getXY
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
protected int[] getXY(String xy) {
xy = xy.trim();
if (StringUtils.isEmpty(xy)) {
return new int[] { -1, -1 };
}
if (!StringUtils.isAlphanumeric(xy)) {
return null;
}
CellReference ref = new CellReference(xy);
return new int[] { ref.getRow() < 0 ? -1 : ref.getRow(), ref.getCol() < 0 ? -1 : ref.getCol() };
}
示例6: parseCellAddress
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* Excelのアドレス形式'A1'を、Pointに変換する。
* @param address
* @return 変換できない場合は、nullを返す。
*/
public static Point parseCellAddress(final String address) {
if(isEmpty(address)) {
return null;
}
final Matcher matcher = PATTERN_CELL_ADREESS.matcher(address);
if(!matcher.matches()) {
return null;
}
final CellReference ref = new CellReference(address.toUpperCase());
return new Point(ref.getCol(), ref.getRow());
}
示例7: toPointAddress
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* 文字列の形式のセルのアドレスを、Point形式に変換する。
* @param address
* @return
*/
public static Point toPointAddress(final String address) {
ArgUtils.notEmpty(address, "address");
CellReference ref = new CellReference(address);
return new Point(ref.getCol(), ref.getRow());
}
示例8: isOverlapped
import org.apache.poi.ss.util.CellReference; //導入方法依賴的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);
}
示例9: getValidCellReference
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static CellReference getValidCellReference(Workbook wb, String ref) {
CellReference cr = getCellReference(wb, ref);
String shName = cr.getSheetName();
if(shName == null || wb.getSheetIndex(shName) < 0 ||
cr.getRow() < 0 || cr.getCol() < 0)
return null;
return cr;
}
示例10: XlsxTableReader
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public XlsxTableReader(CellReference ref, TableFactory<T> factory) {
this.factory = factory;
sheetName = ref.getSheetName();
firstRow = ref.getRow();
prevRow = firstRow;
firstColumn = ref.getCol();
prevColumn = firstColumn;
lastColumn = firstColumn;
}
示例11: XlsTableReader
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public XlsTableReader(CellReference ref, TableFactory<T> factory) {
this.factory = factory;
sheetName = ref.getSheetName();
firstRow = ref.getRow();
firstColumn = ref.getCol();
lastColumn = firstColumn;
prevRow = firstRow;
}
示例12: Cell
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public Cell(CellReference originalCell) {
this(originalCell.getCol(), originalCell.getRow());
}
示例13: extract
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public Map<String, Object[]> extract(Workbook workbook) {
CellValueHelper helper = new CellValueHelper(workbook, true, this.locale);
List<NamedCellInfo> list = ExcelUtils.createNamedCellList(workbook);
Map<String, Object[]> map = new HashMap<String, Object[]>();
for (NamedCellInfo info : list) {
int currentLine = -1;
int includeSize = 0;
boolean hasValue = false;
Sheet sheet = workbook.getSheet(info.
getSheetName());
List<Object> values = new ArrayList<Object>();
for (CellReference cRef : info.getCellList()) {
Cell cell = ExcelUtils.getOrCreateCell(sheet, cRef.getRow(), cRef.getCol());
if (cRef.getRow() != currentLine) {
currentLine = cRef.getRow();
if (hasValue) {
includeSize = values.size();
}
hasValue = false;
}
if (cell.getCellType() == Cell.CELL_TYPE_FORMULA && info.getCellList().size() > 1 && !includeFormulaValue) {
continue;
}
FormattedValue fv = helper.getFormattedValue(cell);
Object value = null;
if (this.convertString) {
value = fv.getValue();
} else if (fv.getRawData() != null) {
value = fv.getRawData();
} else {
switch (fv.getType()) {
case NUMBER:
value = cell.getNumericCellValue();
break;
case DATE:
value = cell.getDateCellValue();
break;
case BOOLEAN:
value = cell.getBooleanCellValue();
break;
default:
value = fv.getValue();
break;
}
}
if (value != null && value.toString().length() > 0) {
hasValue = true;
}
values.add(value);
}
if (hasValue) {
includeSize = values.size();
}
map.put(info.getName(), values.subList(0, includeSize).toArray());
}
return map;
}
示例14: createStepData
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* Setup the data necessary for Excel Writer step
*
* @param fileType
* @throws KettleException
*/
private void createStepData( String fileType ) throws KettleException {
stepData = new ExcelWriterStepData();
stepData.inputRowMeta = step.getInputRowMeta().clone();
stepData.outputRowMeta = step.getInputRowMeta().clone();
// we don't run transformation so ExcelWriterStep.processRow() doesn't get executed
// we populate the ExcelWriterStepData with bare minimum required values
CellReference cellRef = new CellReference( stepMeta.getStartingCell() );
stepData.startingRow = cellRef.getRow();
stepData.startingCol = cellRef.getCol();
stepData.posX = stepData.startingCol;
stepData.posY = stepData.startingRow;
int numOfFields = stepData.inputRowMeta.size();
stepData.fieldnrs = new int[numOfFields];
stepData.linkfieldnrs = new int[numOfFields];
stepData.commentfieldnrs = new int[numOfFields];
for ( int i = 0; i < numOfFields; i++ ) {
stepData.fieldnrs[i] = i;
stepData.linkfieldnrs[i] = -1;
stepData.commentfieldnrs[i] = -1;
}
// we avoid reading/writing Excel files, so ExcelWriterStep.prepareNextOutputFile() doesn't get executed
// create Excel workbook object
stepData.wb = stepMeta.getExtension().equalsIgnoreCase( "xlsx" ) ? new XSSFWorkbook() : new HSSFWorkbook();
stepData.sheet = stepData.wb.createSheet();
stepData.file = null;
stepData.clearStyleCache( numOfFields );
// we avoid reading template file from disk
// so set beforehand cells with custom style and formatting
DataFormat format = stepData.wb.createDataFormat();
Row xlsRow = stepData.sheet.createRow( 0 );
// Cell F1 has custom style applied, used as template
Cell cell = xlsRow.createCell( 5 );
CellStyle cellStyle = stepData.wb.createCellStyle();
cellStyle.setBorderRight( CellStyle.BORDER_THICK );
cellStyle.setFillPattern( CellStyle.FINE_DOTS );
cell.setCellStyle( cellStyle );
// Cell G1 has same style, but also a custom data format
cellStyle = stepData.wb.createCellStyle();
cellStyle.cloneStyleFrom( cell.getCellStyle() );
cell = xlsRow.createCell( 6 );
cellStyle.setDataFormat( format.getFormat( "##0,000.0" ) );
cell.setCellStyle( cellStyle );
}
示例15: CellAddress
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* CellAddressのインスタンスを作成する。
* @param reference セルの參照形式。
*/
public CellAddress(final CellReference reference) {
this(reference.getRow(), reference.getCol());
}