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