Class XlsxParser


  • public class XlsxParser
    extends Object
    A StAX parser to convert Xlsx to JSON format.

    The syntax as follows

    1. All are attributes:

      For example,

      <foo a="a"/>
       
      Result:
      
       {
           "foo": {
               "a": "a"
           }
       }
       
    2. Attributes and child element:

      For example,

      <foo a="a">
           <bar>baz</bar>
       </foo>
       
      Result:
      
       {
           "foo": {
                     "": ["a"], // store for the attr key info
                     "a": "a",  // attribute
                     "bar": {
                    "_": "baz" // text only
                     }
           }
       }
      
    3. Attributes and text node only:

      For example,

      <foo a="a">bar</foo>
       
      Result:
      
       {
           "foo": {
               "a": "a", // attribute
               "_": "baz" // text only
           }
       }
      
    4. Text node only:

      For example,

      <foo>bar</foo>
       
      Result:
      
       {
           "foo": {
               "_": "baz" // text only
           }
       }
      
    5. Child element and text node only:

      For example,

      <foo><bar>baz</bar></foo>
       
      Result:
      
       {
           "foo": {
                     "bar": {
                   "_": "baz" // text only
                     }
           }
       }
      
    6. Multiple child elements with the same key:

      For example,

      <foo><bar a="a"></bar><bar b="b"></bar><baz/></foo>
       
      Result:
      
       {
           "foo": {
               "bar": [{
                          "a": "a"
                      }, {
                    "b": "b"
                      }],
               "baz": null // self-closed tag
            }
       }
      
    Author:
    jumperchen