Package io.keikai.importer
Class XlsxParser
- java.lang.Object
-
- io.keikai.importer.XlsxParser
-
public class XlsxParser extends Object
A StAX parser to convert Xlsx to JSON format.The syntax as follows
- All are attributes:
For example,
Result:<foo a="a"/>
{ "foo": { "a": "a" } }
- Attributes and child element:
For example,
Result:<foo a="a"> <bar>baz</bar> </foo>
{ "foo": { "": ["a"], // store for the attr key info "a": "a", // attribute "bar": { "_": "baz" // text only } } }
- Attributes and text node only:
For example,
Result:<foo a="a">bar</foo>
{ "foo": { "a": "a", // attribute "_": "baz" // text only } }
- Text node only:
For example,
Result:<foo>bar</foo>
{ "foo": { "_": "baz" // text only } }
- Child element and text node only:
For example,
Result:<foo><bar>baz</bar></foo>
{ "foo": { "bar": { "_": "baz" // text only } } }
- Multiple child elements with the same key:
For example,
Result:<foo><bar a="a"></bar><bar b="b"></bar><baz/></foo>
{ "foo": { "bar": [{ "a": "a" }, { "b": "b" }], "baz": null // self-closed tag } }
- Author:
- jumperchen
- All are attributes:
-
-
Constructor Summary
Constructors Constructor Description XlsxParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JSONObject
parse(String name, ZipInputStream zipFile)
static void
parseElement(XMLStreamReader reader, JSONAware json, Map<String,Supplier<JSONNode>> schemaNodes)
static JSONObject
parseXML(XMLStreamReader reader)
-
-
-
Method Detail
-
parse
public static JSONObject parse(String name, ZipInputStream zipFile) throws IOException, XMLStreamException
- Throws:
IOException
XMLStreamException
-
parseXML
public static JSONObject parseXML(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
parseElement
public static void parseElement(XMLStreamReader reader, JSONAware json, Map<String,Supplier<JSONNode>> schemaNodes) throws XMLStreamException
- Throws:
XMLStreamException
-
-