@Override public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { if(localName.equals("td")) { inCell = true; if(needsComma) { super.characters(comma, 0, 1); needsComma = true; } } else { super.startElement(uri, localName, name, atts); } }
@Override public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { if(localName.equals("td")) { inCell = true; if(needsComma) { super.characters(comma, 0, 1); needsComma = true; } } else { super.startElement(uri, localName, name, atts); } }
@Override public void characters(char[] ch, int start, int length) throws SAXException { if(inCell) { StringBuffer t = new StringBuffer(new String(ch,start,length)); // Quote if not all numbers if(all_nums.matcher(t).matches()) { super.characters(ch, start, length); } else { for(int i=t.length()-1; i>=0; i--) { if(t.charAt(i) == '\"') { // Double up double quotes t.insert(i, '\"'); i--; } } t.insert(0, '\"'); t.append('\"'); char[] c = t.toString().toCharArray(); super.characters(c, 0, c.length); } } else { super.characters(ch, start, length); } }
@Override public void characters(char[] ch, int start, int length) throws SAXException { if(inCell) { StringBuffer t = new StringBuffer(new String(ch,start,length)); // Quote if not all numbers if(all_nums.matcher(t).matches()) { super.characters(ch, start, length); } else { for(int i=t.length()-1; i>=0; i--) { if(t.charAt(i) == '\"') { // Double up double quotes t.insert(i, '\"'); i--; } } t.insert(0, '\"'); t.append('\"'); char[] c = t.toString().toCharArray(); super.characters(c, 0, c.length); } } else { super.characters(ch, start, length); } }