import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
private StringBuffer formula = new StringBuffer();
private StringBuffer headerFooter = new StringBuffer();
- private Queue<CellReference> commentCellRefs;
+ private Queue<CellAddress> commentCellRefs;
/**
* Accepts objects needed while parsing.
@SuppressWarnings("deprecation")
private void init() {
if (commentsTable != null) {
- commentCellRefs = new LinkedList<CellReference>();
+ commentCellRefs = new LinkedList<CellAddress>();
for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) {
- commentCellRefs.add(new CellReference(comment.getRef()));
+ commentCellRefs.add(new CellAddress(comment.getRef()));
}
}
}
// Do we have a comment for this cell?
checkForEmptyCellComments(EmptyCellCommentsCheckType.CELL);
- XSSFComment comment = commentsTable != null ? commentsTable.findCellComment(cellRef) : null;
+ XSSFComment comment = commentsTable != null ? commentsTable.findCellComment(new CellAddress(cellRef)) : null;
// Output
output.cell(cellRef, thisStr, comment);
}
}
- CellReference nextCommentCellRef;
+ CellAddress nextCommentCellRef;
do {
- CellReference cellRef = new CellReference(this.cellRef);
- CellReference peekCellRef = commentCellRefs.peek();
+ CellAddress cellRef = new CellAddress(this.cellRef);
+ CellAddress peekCellRef = commentCellRefs.peek();
if (type == EmptyCellCommentsCheckType.CELL && cellRef.equals(peekCellRef)) {
// remove the comment cell ref from the list if we're about to handle it alongside the cell content
commentCellRefs.remove();
return;
} else {
// fill in any gaps if there are empty cells with comment mixed in with non-empty cells
- int comparison = cellRefComparator.compare(peekCellRef, cellRef);
+ int comparison = peekCellRef.compareTo(cellRef);
if (comparison > 0 && type == EmptyCellCommentsCheckType.END_OF_ROW && peekCellRef.getRow() <= rowNum) {
nextCommentCellRef = commentCellRefs.remove();
outputEmptyCellComment(nextCommentCellRef);
/**
* Output an empty-cell comment.
*/
- private void outputEmptyCellComment(CellReference cellRef) {
- String cellRefString = cellRef.formatAsString();
- XSSFComment comment = commentsTable.findCellComment(cellRefString);
- output.cell(cellRefString, null, comment);
+ private void outputEmptyCellComment(CellAddress cellRef) {
+ XSSFComment comment = commentsTable.findCellComment(cellRef);
+ output.cell(cellRef.formatAsString(), null, comment);
}
private enum EmptyCellCommentsCheckType {
END_OF_ROW,
END_OF_SHEET_DATA
}
- private static final Comparator<CellReference> cellRefComparator = new Comparator<CellReference>() {
- @Override
- public int compare(CellReference o1, CellReference o2) {
- int result = compare(o1.getRow(), o2.getRow());
- if (result == 0) {
- result = compare(o1.getCol(), o2.getCol());
- }
- return result;
- }
- public int compare(int x, int y) {
- return (x < y) ? -1 : ((x == y) ? 0 : 1);
- }
- };
/**
* You need to implement this to handle the results