pjfanning commented on code in PR #920:
URL: https://github.com/apache/poi/pull/920#discussion_r2440409261
##########
poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java:
##########
@@ -133,86 +189,107 @@ private void beforeCellValue(byte[] data) {
checkMissedComments(currentRow, cellBuffer.getColNum());
}
- private void handleCellValue(String formattedValue) {
- CellAddress cellAddress = new CellAddress(currentRow,
cellBuffer.getColNum());
+ private void handleStringCellValue(String formattedValue) {
+ CellAddress cellAddress = getCellAddress();
+ XSSFBComment comment = getCellComment(cellAddress);
+ handler.stringCell(cellAddress.formatAsString(), formattedValue,
comment);
+ }
+
+ private void handleDoubleCellValue(double val) {
+ CellAddress cellAddress = getCellAddress();
+ XSSFBComment comment = getCellComment(cellAddress);
+ ExcelNumberFormat nf = getExcelNumberFormat();
+ handler.doubleCell(cellAddress.formatAsString(), val, comment, nf);
+ }
+
+ private CellAddress getCellAddress() {
+ return new CellAddress(currentRow, cellBuffer.getColNum());
+ }
+
+ private XSSFBComment getCellComment(CellAddress cellAddress) {
XSSFBComment comment = null;
if (comments != null) {
- comment = comments.get(cellAddress);
Review Comment:
Why change the formatting?
##########
poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java:
##########
@@ -114,7 +170,7 @@ public void handleRecord(int id, byte[] data) throws
XSSFBParseException {
handleFmlaNum(data);
break;
case BrtFmlaError:
- handleFmlaError(data);
+ handleCellError(data);
Review Comment:
Why is this changed?
##########
poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java:
##########
@@ -55,6 +56,54 @@ public class XSSFBSheetHandler extends XSSFBParser {
private StringBuilder xlWideStringBuffer = new StringBuilder();
private final XSSFBCellHeader cellBuffer = new XSSFBCellHeader();
+
+ /**
+ * Creates a handler that forwards native POI cell types to the supplied
{@link
+ * XSSFBSheetContentsHandler}.
+ *
+ * <p>Select this overload when the consumer expects the raw cell
representation rather than
+ * formatted strings.
+ *
+ * @param is XLSB worksheet stream to parse
+ * @param styles table providing cell style and number format metadata
+ * @param comments optional comments table, may be {@code null}
+ * @param strings shared strings table used by the sheet
+ * @param sheetContentsHandler callback receiving native cell events
+ * @param formulasNotResults {@code true} to request formulas rather than
cached results
Review Comment:
If you are not implementing this param then remove it
##########
poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java:
##########
@@ -55,6 +56,54 @@ public class XSSFBSheetHandler extends XSSFBParser {
private StringBuilder xlWideStringBuffer = new StringBuilder();
private final XSSFBCellHeader cellBuffer = new XSSFBCellHeader();
+
+ /**
+ * Creates a handler that forwards native POI cell types to the supplied
{@link
+ * XSSFBSheetContentsHandler}.
+ *
+ * <p>Select this overload when the consumer expects the raw cell
representation rather than
+ * formatted strings.
+ *
+ * @param is XLSB worksheet stream to parse
+ * @param styles table providing cell style and number format metadata
+ * @param comments optional comments table, may be {@code null}
+ * @param strings shared strings table used by the sheet
+ * @param sheetContentsHandler callback receiving native cell events
+ * @param formulasNotResults {@code true} to request formulas rather than
cached results
+ * (currently not implemented)
+ */
+ public XSSFBSheetHandler(InputStream is,
+ XSSFBStylesTable styles,
+ XSSFBCommentsTable comments,
+ SharedStrings strings,
+ XSSFBSheetContentsHandler sheetContentsHandler,
+ boolean formulasNotResults) {
+ super(is);
+ this.styles = styles;
+ this.comments = comments;
+ this.stringsTable = strings;
+ this.handler = sheetContentsHandler;
+ this.formulasNotResults = formulasNotResults;
+ }
+
+ /**
+ * Creates a handler that converts numeric and date cells to formatted
strings via {@link
+ * DataFormatter}.
+ *
+ * <p>Select this overload when the consumer expects formatted string
values rather than raw
+ * cell representations.
+ *
+ * @param is XLSB worksheet stream to parse
+ * @param styles table providing cell style and number format metadata
+ * @param comments optional comments table, may be {@code null}
+ * @param strings shared strings table used by the sheet
+ * @param sheetContentsHandler callback receiving formatted string values
+ * @param dataFormatter formatter applied to numeric and date cells
+ * @param formulasNotResults {@code true} to request formulas rather than
cached results
Review Comment:
Remove this param
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]