arjansh commented on a change in pull request #234: MM-82 Detect Column Types
URL: https://github.com/apache/metamodel/pull/234#discussion_r355415266
 
 

 ##########
 File path: excel/src/main/java/org/apache/metamodel/excel/ExcelUtils.java
 ##########
 @@ -281,6 +356,51 @@ private static String getFormulaCellValue(Workbook wb, 
Cell cell) {
         return cell.getCellFormula();
     }
 
+    private static Object getFormulaCellValueAsObject(final Workbook workbook, 
final Cell cell) {
+        // first try with a cached/precalculated value
+        try {
+            return getDoubleAsNumber(cell.getNumericCellValue());
+        } catch (final Exception e) {
+            if (logger.isInfoEnabled()) {
+                logger.info("Failed to fetch cached/precalculated formula 
value of cell: " + cell, e);
+            }
+        }
+
+        // evaluate cell first, if possible
+        try {
 
 Review comment:
   This piece of code looks like a carbon copy of line 326-348, with the only 
difference that in those lines, on line 339 you invoke `getCellValue`, where 
here on line 377 you invoke `getCallValueAsObject`,  I would propose you 
refactor this to get rid of the duplicated boiler plate code around these 
invocations (so it's no longer duplicated, just available once).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to