Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-223

Format parser doesn't account for currency VND format, parse as date

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 5.2.0
    • 5.1.1, 5.2.0
    • None
    • Security Level: Jimmy
    • None
    • None

      Steps to reproduce

      Use attached xlsx as src for a spreadsheet

      issue trigger if a VND formatted cell uses a negative value.

      In log:

       

      java.lang.NullPointerExceptionjava.lang.NullPointerException at org.zkoss.poi.ss.format.CellFormat.apply(CellFormat.java:254) at io.keikai.model.impl.sys.FormatEngineImpl.format0(FormatEngineImpl.java:108) at io.keikai.model.impl.sys.FormatEngineImpl.format(FormatEngineImpl.java:70) at io.keikai.ui.impl.CellFormatHelper.getFormatResult(CellFormatHelper.java:974) at io.keikai.ui.SpreadsheetCtrlImpl.getCellAttr(SpreadsheetCtrlImpl.java:535) at io.keikai.ui.SpreadsheetCtrlImpl.getRangeAttrs(SpreadsheetCtrlImpl.java:382) at io.keikai.ui.Spreadsheet.createActiveRange(Spreadsheet.java:1800) at io.keikai.ui.Spreadsheet.renderProperties(Spreadsheet.java:1753) at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2175) at org.zkoss.zk.ui.AbstractComponent.redrawChildren(AbstractComponent.java:2266) at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2207) at org.zkoss.zk.ui.sys.HtmlPageRenders.outPageContent(HtmlPageRenders.java:670) at org.zkoss.zul.impl.PageRenderer.renderDesktop(PageRenderer.java:99) at org.zkoss.zul.impl.PageRenderer.render(PageRenderer.java:56) at org.zkoss.zk.ui.impl.PageImpl.redraw(PageImpl.java:931) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:579) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:374) at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:215) at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:140) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      

       

       

      The cell format  string (as seen in org.zkoss.poi.ss.format.CellFormat.CellFormat(String)  )

      [$VND]\ #,##0.00_);[Red]([$VND]\ #,##0.00)

      when parsing the direction during new CellFormatPart(valueDesc)  (org.zkoss.poi.ss.format.CellFormat.CellFormat(String) line 196)

      then to  type = getCellFormatType(m); (org.zkoss.poi.ss.format.CellFormatPart.CellFormatPart(String) line 205)

      and is parsed at

      org.zkoss.poi.ss.format.CellFormatPart.formatType(String)

      During parsing, the first members evaluated are (written here separated by | )

      \ | [ | $ | V | N | D

      each member until D are not matched to a type, but D matches to Date type. and the method resolves with

      return CellFormatType.DATE; (line 410), which case another exception, resulting in the final NPE

      java.lang.IllegalArgumentException: Illegal pattern character 'V'java.lang.IllegalArgumentException: Illegal pattern character 'V' at java.text.SimpleDateFormat.compile(Unknown Source) at java.text.SimpleDateFormat.initialize(Unknown Source) at java.text.SimpleDateFormat.<init>(Unknown Source) at org.zkoss.poi.ss.format.CellDateFormatter.<init>(CellDateFormatter.java:183) at org.zkoss.poi.ss.format.CellFormatType$3.formatter(CellFormatType.java:53) at org.zkoss.poi.ss.format.CellFormatPart.getFormatter(CellFormatPart.java:374) at org.zkoss.poi.ss.format.CellFormatPart.<init>(CellFormatPart.java:206) at org.zkoss.poi.ss.format.CellFormat.<init>(CellFormat.java:196) at org.zkoss.poi.ss.format.CellFormat.getInstance(CellFormat.java:172) at io.keikai.model.impl.sys.FormatEngineImpl.getCellFormat(FormatEngineImpl.java:79) at io.keikaiex.model.sys.FormatEngineEx.getCellFormat(FormatEngineEx.java:46) at io.keikai.model.impl.sys.FormatEngineImpl.format0(FormatEngineImpl.java:98) at io.keikai.model.impl.sys.FormatEngineImpl.format(FormatEngineImpl.java:70) at io.keikai.ui.impl.CellFormatHelper.getFormatResult(CellFormatHelper.java:974) at io.keikai.ui.SpreadsheetCtrlImpl.getCellAttr(SpreadsheetCtrlImpl.java:535) at io.keikai.ui.SpreadsheetCtrlImpl.getRangeAttrs(SpreadsheetCtrlImpl.java:382) at io.keikai.ui.Spreadsheet.createActiveRange(Spreadsheet.java:1800) at io.keikai.ui.Spreadsheet.renderProperties(Spreadsheet.java:1753) at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2175) at org.zkoss.zk.ui.AbstractComponent.redrawChildren(AbstractComponent.java:2266) at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2207) at org.zkoss.zk.ui.sys.HtmlPageRenders.outPageContent(HtmlPageRenders.java:670) at org.zkoss.zul.impl.PageRenderer.renderDesktop(PageRenderer.java:99) at org.zkoss.zul.impl.PageRenderer.render(PageRenderer.java:56) at org.zkoss.zk.ui.impl.PageImpl.redraw(PageImpl.java:931) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:579) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:374) at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:215) at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:140) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      

            wenninghsu wenninghsu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: