|
|
|
@ -177,6 +177,7 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser {
|
|
|
|
|
XmlParserFactory.parse(workbookXml, new DefaultHandler() { |
|
|
|
|
|
|
|
|
|
private int id = 0; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { |
|
|
|
|
if (qName.toLowerCase(Locale.US).equals("sheet")) { |
|
|
|
@ -223,28 +224,54 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser {
|
|
|
|
|
//this.sharedStringsTable.readFrom(inputStream);
|
|
|
|
|
|
|
|
|
|
XmlParserFactory.parse(inputStream, new DefaultHandler() { |
|
|
|
|
int lastElementPosition = -1; |
|
|
|
|
//int lastElementPosition = -1;
|
|
|
|
|
//
|
|
|
|
|
//int lastHandledElementPosition = -1;
|
|
|
|
|
|
|
|
|
|
String beforeQName = ""; |
|
|
|
|
|
|
|
|
|
int lastHandledElementPosition = -1; |
|
|
|
|
String currentQName = ""; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void startElement(String uri, String localName, String qName, Attributes attributes) { |
|
|
|
|
if (hasSkippedEmptySharedString()) { |
|
|
|
|
sharedStringList.add(""); |
|
|
|
|
//if (hasSkippedEmptySharedString()) {
|
|
|
|
|
// sharedStringList.add("");
|
|
|
|
|
//}
|
|
|
|
|
//if ("t".equals(qName)) {
|
|
|
|
|
// lastElementPosition++;
|
|
|
|
|
//}
|
|
|
|
|
if ("si".equals(qName) || "t".equals(qName)) { |
|
|
|
|
beforeQName = currentQName; |
|
|
|
|
currentQName = qName; |
|
|
|
|
} |
|
|
|
|
if ("t".equals(qName)) { |
|
|
|
|
lastElementPosition++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean hasSkippedEmptySharedString() { |
|
|
|
|
return lastElementPosition > lastHandledElementPosition; |
|
|
|
|
} |
|
|
|
|
//@Override
|
|
|
|
|
//public void endElement (String uri, String localName, String qName)
|
|
|
|
|
// throws SAXException
|
|
|
|
|
//{
|
|
|
|
|
// if ("si".equals(qName) || "t".equals(qName)) {
|
|
|
|
|
// beforeQName = qName;
|
|
|
|
|
// currentQName = "";
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private boolean hasSkippedEmptySharedString() {
|
|
|
|
|
// return lastElementPosition > lastHandledElementPosition;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void characters(char[] ch, int start, int length) { |
|
|
|
|
sharedStringList.add(new String(ch, start, length)); |
|
|
|
|
lastHandledElementPosition++; |
|
|
|
|
if ("t".equals(currentQName) && ("t".equals(beforeQName))) { |
|
|
|
|
String pre = sharedStringList.get(sharedStringList.size() - 1); |
|
|
|
|
String str = pre + new String(ch, start, length); |
|
|
|
|
sharedStringList.remove(sharedStringList.size() - 1); |
|
|
|
|
sharedStringList.add(str); |
|
|
|
|
}else if ("t".equals(currentQName) && ("si".equals(beforeQName))){ |
|
|
|
|
sharedStringList.add(new String(ch, start, length)); |
|
|
|
|
} |
|
|
|
|
// lastHandledElementPosition++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|