ASF Bugzilla – Attachment 35586 Details for
Bug 61858
Getting double value from the method "cell" of interface "SheetContentsHandler" of "XSSFSheetXMLHandler" class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Changes that give the double value of the cell to output
Getting_double_value_from_XSSFSheetXMLHandler_new.patch (text/plain), 6.37 KB, created by
Phaneeswar
on 2017-12-05 12:57:44 UTC
(
hide
)
Description:
Changes that give the double value of the cell to output
Filename:
MIME Type:
Creator:
Phaneeswar
Created:
2017-12-05 12:57:44 UTC
Size:
6.37 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java >IDEA additional info: >Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP ><+>UTF-8 >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (revision 58114c6d8c80403353b76d2fbb098b39c5341f49) >+++ src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (revision ) >@@ -37,7 +37,7 @@ > import org.xml.sax.helpers.DefaultHandler; > > /** >- * This class handles the processing of a sheet#.xml >+ * This class handles the processing of a sheet#.xml > * sheet part of a XSSF .xlsx file, and generates > * row and cell events for it. > */ >@@ -57,7 +57,7 @@ > SST_STRING, > NUMBER, > } >- >+ > /** > * Table with the styles used for formatting > */ >@@ -130,7 +130,7 @@ > this.formatter = dataFormatter; > init(); > } >- >+ > /** > * Accepts objects needed while parsing. > * >@@ -145,7 +145,7 @@ > boolean formulasNotResults) { > this(styles, null, strings, sheetContentsHandler, dataFormatter, formulasNotResults); > } >- >+ > /** > * Accepts objects needed while parsing. > * >@@ -159,7 +159,7 @@ > boolean formulasNotResults) { > this(styles, strings, sheetContentsHandler, new DataFormatter(), formulasNotResults); > } >- >+ > private void init() { > if (commentsTable != null) { > commentCellRefs = new LinkedList<>(); >@@ -167,7 +167,7 @@ > for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) { > commentCellRefs.add(new CellAddress(comment.getRef())); > } >- } >+ } > } > > private boolean isTextTag(String name) { >@@ -186,7 +186,7 @@ > // It isn't a text tag > return false; > } >- >+ > @Override > @SuppressWarnings("unused") > public void startElement(String uri, String localName, String qName, >@@ -206,26 +206,26 @@ > } else if ("f".equals(localName)) { > // Clear contents cache > formula.setLength(0); >- >+ > // Mark us as being a formula if not already > if(nextDataType == xssfDataType.NUMBER) { > nextDataType = xssfDataType.FORMULA; > } >- >+ > // Decide where to get the formula string from > String type = attributes.getValue("t"); > if(type != null && type.equals("shared")) { > // Is it the one that defines the shared, or uses it? > String ref = attributes.getValue("ref"); > String si = attributes.getValue("si"); >- >+ > if(ref != null) { > // This one defines it > // TODO Save it somewhere > fIsOpen = true; > } else { > // This one uses a shared formula >- // TODO Retrieve the shared formula and tweak it to >+ // TODO Retrieve the shared formula and tweak it to > // match the current cell > if(formulasNotResults) { > logger.log(POILogger.WARN, "shared formulas not yet supported!"); >@@ -303,11 +303,12 @@ > } > > String thisStr = null; >+ Double doubleValue = null; > > // v => contents of a cell > if (isTextTag(localName)) { > vIsOpen = false; >- >+ > // Process the value contents as required, now we have it all > switch (nextDataType) { > case BOOLEAN: >@@ -324,7 +325,7 @@ > thisStr = formula.toString(); > } else { > String fv = value.toString(); >- >+ > if (this.formatString != null) { > try { > // Try to use the value as a formattable number >@@ -365,19 +366,20 @@ > thisStr = formatter.formatRawCellContents(Double.parseDouble(n), this.formatIndex, this.formatString); > else > thisStr = n; >+ doubleValue = Double.parseDouble(n); > break; > > default: > thisStr = "(TODO: Unexpected type: " + nextDataType + ")"; > break; > } >- >+ > // Do we have a comment for this cell? > checkForEmptyCellComments(EmptyCellCommentsCheckType.CELL); > XSSFComment comment = commentsTable != null ? commentsTable.findCellComment(new CellAddress(cellRef)) : null; >- >+ > // Output >- output.cell(cellRef, thisStr, comment); >+ output.cell(cellRef, thisStr, doubleValue, comment); > } else if ("f".equals(localName)) { > fIsOpen = false; > } else if ("is".equals(localName)) { >@@ -385,10 +387,10 @@ > } else if ("row".equals(localName)) { > // Handle any "missing" cells which had comments attached > checkForEmptyCellComments(EmptyCellCommentsCheckType.END_OF_ROW); >- >+ > // Finish up the row > output.endRow(rowNum); >- >+ > // some sheets do not have rowNum set in the XML, Excel can read them so we should try to read them as well > nextRowNum = rowNum + 1; > } else if ("sheetData".equals(localName)) { >@@ -427,7 +429,7 @@ > headerFooter.append(ch, start, length); > } > } >- >+ > /** > * Do a check for, and output, comments in otherwise empty cells. > */ >@@ -491,7 +493,7 @@ > XSSFComment comment = commentsTable.findCellComment(cellRef); > output.cell(cellRef.formatAsString(), null, comment); > } >- >+ > private enum EmptyCellCommentsCheckType { > CELL, > END_OF_ROW, >@@ -510,9 +512,10 @@ > public void endRow(int rowNum); > > /** >- * A cell, with the given formatted value (may be null), >+ * A cell, with the given formatted value (may be null), >+ * with the double value (may be null), > * and possibly a comment (may be null), was encountered */ >- public void cell(String cellReference, String formattedValue, XSSFComment comment); >+ public void cell(String cellReference, String formattedValue, Double doubleValue, XSSFComment comment); > > /** A header or footer has been encountered */ > public default void headerFooter(String text, boolean isHeader, String tagName) {}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 61858
: 35586