Package io.keikai.importer
Class XlsxParser
java.lang.Object
io.keikai.importer.XlsxParser
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JSONObjectparse(String name, ZipInputStream zipFile) static voidparseElement(XMLStreamReader reader, JSONAware json, Map<String, Supplier<JSONNode>> schemaNodes) static JSONObjectparseXML(XMLStreamReader reader)
-
Constructor Details
-
XlsxParser
public XlsxParser()
-
-
Method Details
-
parse
public static JSONObject parse(String name, ZipInputStream zipFile) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
parseXML
- Throws:
XMLStreamException
-
parseElement
public static void parseElement(XMLStreamReader reader, JSONAware json, Map<String, Supplier<JSONNode>> schemaNodes) throws XMLStreamException- Throws:
XMLStreamException
-