log.warn( msg);
continue;
}
log.debug( String.format( "cellPr [%s] being procesed", cellPr.getUniqueName()));
final CTXmlPr pr = cellPr.getXmlPr();
assert pr!=null;
if( pr==null ) {
final String msg = String.format( "xmlPr for cell [%d] uniqueName [%s] is null. Will be ignored", sc.getId(), cellPr.getUniqueName() );
log.warn( msg);
continue;
}
final String xpath = pr.getXpath();
assert xpath!=null;
if( xpath==null ) {
final String msg = String.format( "xpath attribute for xmlPr for cell [%d] uniqueName [%s] is null. Will be ignored", sc.getId(), cellPr.getUniqueName() );
log.warn( msg);
continue;
}
// PERFORM AN XPATH QUERY
final String xpathQuery = String.format( "$this%s", xpath );
log.debug( String.format( "perfrom xpath query [%s]", xpathQuery) );
XmlObject[] bindValues = xmlSourceObject.selectPath(xpathQuery);
assert bindValues!=null;
if( bindValues==null ) {
final String msg = String.format( "No values match for xpath query [%s] for cell [%d] uniqueName [%s]. Cell will be ignored", xpathQuery, sc.getId(), cellPr.getUniqueName() );
log.warn( msg);
continue;
}
assert bindValues.length == 1: "bindValues.length=" + bindValues.length;
if( bindValues.length!=1) {
final String msg = String.format( "Result of xpath query [%s] doesn't match with just one value but with [%d]. Cell will be ignored", xpathQuery, bindValues.length );
log.warn( msg);
continue;
}
final int rowNum = cellRef.getRow();
XSSFRow row = sheet.getRow(rowNum);
if( row == null ) {
row = sheet.createRow(rowNum);
}
assert row!=null;
if( row==null ) {
final String msg = String.format( "detected problem to get/create row [%d]. Will be ignored!", rowNum );
log.warn( msg);
continue;
}
final int cellNum = cellRef.getCol();
XSSFCell cell = row.getCell( cellNum, Row.CREATE_NULL_AS_BLANK );
assert cell!=null;
if( cell==null ) {
final String msg = String.format( "detected problem to get cell [%d,%d]. Will be ignored!", rowNum, cellNum );
log.warn( msg);
continue;
}
final XmlObject value = bindValues[0];
setCellValue( cell, value, pr.getXmlDataType() );
//cell.setCellValue( ((SimpleValue)value).getStringValue() );
}
}