private void handleEvent(XMLEvent event) {
    if(event.getEventType() == XMLStreamConstants.CHARACTERS) {
      Characters c = event.asCharacters();
      lastContents += c.getData();
    } else if(event.getEventType() == XMLStreamConstants.START_ELEMENT
        && isSpreadsheetTag(event.asStartElement().getName())) {
      StartElement startElement = event.asStartElement();
      String tagLocalName = startElement.getName().getLocalPart();

      if("row".equals(tagLocalName)) {
        Attribute rowNumAttr = startElement.getAttributeByName(new QName("r"));
        int rowIndex = currentRowNum;
        if(rowNumAttr != null) {
          rowIndex = Integer.parseInt(rowNumAttr.getValue()) - 1;
          currentRowNum = rowIndex;
        }
        Attribute isHiddenAttr = startElement.getAttributeByName(new QName("hidden"));
        boolean isHidden = isHiddenAttr != null && ("1".equals(isHiddenAttr.getValue()) || "true".equals(isHiddenAttr.getValue()));
        currentRow = new StreamingRow(rowIndex, isHidden);
        currentColNum = firstColNum;
      } else if("col".equals(tagLocalName)) {
        Attribute isHiddenAttr = startElement.getAttributeByName(new QName("hidden"));
        boolean isHidden = isHiddenAttr != null && ("1".equals(isHiddenAttr.getValue()) || "true".equals(isHiddenAttr.getValue()));
        if(isHidden) {
          Attribute minAttr = startElement.getAttributeByName(new QName("min"));
          Attribute maxAttr = startElement.getAttributeByName(new QName("max"));
          int min = Integer.parseInt(minAttr.getValue()) - 1;
          int max = Integer.parseInt(maxAttr.getValue()) - 1;
          for(int columnIndex = min; columnIndex <= max; columnIndex++)
            hiddenColumns.add(columnIndex);
        }
      } else if("c".equals(tagLocalName)) {
        Attribute ref = startElement.getAttributeByName(new QName("r"));

        if(ref != null) {
          String[] coord = splitCellRef(ref.getValue());
          currentColNum = CellReference.convertColStringToIndex(coord[0]);
          currentCell = new StreamingCell(currentColNum, Integer.parseInt(coord[1]) - 1, use1904Dates);
        } else {
          currentCell = new StreamingCell(currentColNum, currentRowNum, use1904Dates);
        }
        setFormatString(startElement, currentCell);

        Attribute type = startElement.getAttributeByName(new QName("t"));
        if(type != null) {
          currentCell.setType(type.getValue());
        } else {
          currentCell.setType("n");
        }

        Attribute style = startElement.getAttributeByName(new QName("s"));
        if(style != null) {
          String indexStr = style.getValue();
          try {
            int index = Integer.parseInt(indexStr);
            currentCell.setCellStyle(stylesTable.getStyleAt(index));
          } catch(NumberFormatException nfe) {
            log.warn("Ignoring invalid style index {}", indexStr);
          }
        } else {
          currentCell.setCellStyle(stylesTable.getStyleAt(0));
        }
      } else if("dimension".equals(tagLocalName)) {
        Attribute refAttr = startElement.getAttributeByName(new QName("ref"));
        String ref = refAttr != null ? refAttr.getValue() : null;
        if(ref != null) {
          // ref is formatted as A1 or A1:F25. Take the last numbers of this string and use it as lastRowNum
          for(int i = ref.length() - 1; i >= 0; i--) {
            if(!Character.isDigit(ref.charAt(i))) {
              try {
                lastRowNum = Integer.parseInt(ref.substring(i + 1)) - 1;
              } catch(NumberFormatException ignore) { }
              break;
            }
          }
          for(int i = 0; i < ref.length(); i++) {
            if(!Character.isAlphabetic(ref.charAt(i))) {
              firstColNum = CellReference.convertColStringToIndex(ref.substring(0, i));
              break;
            }
          }
        }
      } else if("f".equals(tagLocalName)) {
        if (currentCell != null) {
          currentCell.setFormulaType(true);
        }
      }

      // Clear contents cache
      lastContents = "";
    } else if(event.getEventType() == XMLStreamConstants.END_ELEMENT
        && isSpreadsheetTag(event.asEndElement().getName())) {
      EndElement endElement = event.asEndElement();
      String tagLocalName = endElement.getName().getLocalPart();

      if("v".equals(tagLocalName) || "t".equals(tagLocalName)) {
        currentCell.setRawContents(unformattedContents());
        currentCell.setContentSupplier(formattedContents());
      } else if("row".equals(tagLocalName) && currentRow != null) {
        rowCache.add(currentRow);
        currentRowNum++;
      } else if("c".equals(tagLocalName)) {
        currentRow.getCellMap().put(currentCell.getColumnIndex(), currentCell);
        currentCell = null;
        currentColNum++;
      } else if("f".equals(tagLocalName)) {
        if (currentCell != null) {
          currentCell.setFormula(lastContents);
        }
      }

    }
  }
private void handleEvent ( XMLEvent event ) { if ( event . getEventType ( ) == XMLStreamConstants . CHARACTERS ) { Characters c = event . asCharacters ( ) ; lastContents += c . getData ( ) ; } else if ( event . getEventType ( ) == XMLStreamConstants . START_ELEMENT && isSpreadsheetTag ( event . asStartElement ( ) . getName ( ) ) ) { StartElement startElement = event . asStartElement ( ) ; String tagLocalName = startElement . getName ( ) . getLocalPart ( ) ; if ( "row" . equals ( tagLocalName ) ) { Attribute rowNumAttr = startElement . getAttributeByName ( new QName ( "r" ) ) ; int rowIndex = currentRowNum ; if ( rowNumAttr != null ) { rowIndex = Integer . parseInt ( rowNumAttr . getValue ( ) ) - 1 ; currentRowNum = rowIndex ; } Attribute isHiddenAttr = startElement . getAttributeByName ( new QName ( "hidden" ) ) ; boolean isHidden = isHiddenAttr != null && ( "1" . equals ( isHiddenAttr . getValue ( ) ) || "true" . equals ( isHiddenAttr . getValue ( ) ) ) ; currentRow = new StreamingRow ( rowIndex , isHidden ) ; currentColNum = firstColNum ; } else if ( "col" . equals ( tagLocalName ) ) { Attribute isHiddenAttr = startElement . getAttributeByName ( new QName ( "hidden" ) ) ; boolean isHidden = isHiddenAttr != null && ( "1" . equals ( isHiddenAttr . getValue ( ) ) || "true" . equals ( isHiddenAttr . getValue ( ) ) ) ; if ( isHidden ) { Attribute minAttr = startElement . getAttributeByName ( new QName ( "min" ) ) ; Attribute maxAttr = startElement . getAttributeByName ( new QName ( "max" ) ) ; int min = Integer . parseInt ( minAttr . getValue ( ) ) - 1 ; int max = Integer . parseInt ( maxAttr . getValue ( ) ) - 1 ; for ( int columnIndex = min ; columnIndex <= max ; columnIndex ++ ) hiddenColumns . add ( columnIndex ) ; } } else if ( "c" . equals ( tagLocalName ) ) { Attribute ref = startElement . getAttributeByName ( new QName ( "r" ) ) ; if ( ref != null ) { String [ ] coord = splitCellRef ( ref . getValue ( ) ) ; currentColNum = CellReference . convertColStringToIndex ( coord [ 0 ] ) ; currentCell = new StreamingCell ( currentColNum , Integer . parseInt ( coord [ 1 ] ) - 1 , use1904Dates ) ; } else { currentCell = new StreamingCell ( currentColNum , currentRowNum , use1904Dates ) ; } setFormatString ( startElement , currentCell ) ; Attribute type = startElement . getAttributeByName ( new QName ( "t" ) ) ; if ( type != null ) { currentCell . setType ( type . getValue ( ) ) ; } else { currentCell . setType ( "n" ) ; } Attribute style = startElement . getAttributeByName ( new QName ( "s" ) ) ; if ( style != null ) { String indexStr = style . getValue ( ) ; try { int index = Integer . parseInt ( indexStr ) ; currentCell . setCellStyle ( stylesTable . getStyleAt ( index ) ) ; } catch ( NumberFormatException nfe ) { log . warn ( "Ignoring invalid style index {}" , indexStr ) ; } } else { currentCell . setCellStyle ( stylesTable . getStyleAt ( 0 ) ) ; } } else if ( "dimension" . equals ( tagLocalName ) ) { Attribute refAttr = startElement . getAttributeByName ( new QName ( "ref" ) ) ; String ref = refAttr != null ? refAttr . getValue ( ) : null ; if ( ref != null ) { for ( int i = ref . length ( ) - 1 ; i >= 0 ; i -- ) { if ( ! Character . isDigit ( ref . charAt ( i ) ) ) { try { lastRowNum = Integer . parseInt ( ref . substring ( i + 1 ) ) - 1 ; } catch ( NumberFormatException ignore ) { } break ; } } for ( int i = 0 ; i < ref . length ( ) ; i ++ ) { if ( ! Character . isAlphabetic ( ref . charAt ( i ) ) ) { firstColNum = CellReference . convertColStringToIndex ( ref . substring ( 0 , i ) ) ; break ; } } } } else if ( "f" . equals ( tagLocalName ) ) { if ( currentCell != null ) { currentCell . setFormulaType ( true ) ; } } lastContents = "" ; } else if ( event . getEventType ( ) == XMLStreamConstants . END_ELEMENT && isSpreadsheetTag ( event . asEndElement ( ) . getName ( ) ) ) { EndElement endElement = event . asEndElement ( ) ; String tagLocalName = endElement . getName ( ) . getLocalPart ( ) ; if ( "v" . equals ( tagLocalName ) || "t" . equals ( tagLocalName ) ) { currentCell . setRawContents ( unformattedContents ( ) ) ; currentCell . setContentSupplier ( formattedContents ( ) ) ; } else if ( "row" . equals ( tagLocalName ) && currentRow != null ) { rowCache . add ( currentRow ) ; currentRowNum ++ ; } else if ( "c" . equals ( tagLocalName ) ) { currentRow . getCellMap ( ) . put ( currentCell . getColumnIndex ( ) , currentCell ) ; currentCell = null ; currentColNum ++ ; } else if ( "f" . equals ( tagLocalName ) ) { if ( currentCell != null ) { currentCell . setFormula ( lastContents ) ; } } } }
Handles a SAX event.

@param event