Search in sources :

Example 1 with DataFormatException

use of com.cubrid.common.ui.cubrid.table.dialog.DataFormatException in project cubrid-manager by CUBRID.

the class XlsxReaderHandler method endElement.

/**
	 * response the event end an element
	 *
	 * @param uri the uri of namespace
	 * @param localName the local name
	 * @param name the element name
	 * @throws SAXException the SAXException
	 */
public void endElement(String uri, String localName, String name) throws SAXException {
    if ("v".equals(name) || "t".equals(name)) {
        if (nextIsString) {
            try {
                int idx = Integer.parseInt(lastContents);
                lastContents = new XSSFRichTextString(sharedStringTable.getEntryAt(idx)).toString();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        String value = lastContents;
        if ("".equals(value)) {
            return;
        }
        value = "".equals(value) ? " " : value;
        int cols = currentCol - preCol;
        if (cols > 1) {
            for (int i = 0; i < cols - 1; i++) {
                rowlist.add(preCol, "");
            }
        }
        preCol = currentCol;
        rowlist.add(currentCol - 1, value);
    } else {
        if ("row".equals(name)) {
            if (rowlist.isEmpty()) {
                return;
            }
            int tmpCols = rowlist.size();
            if (currentRow > this.titleRow && tmpCols < this.colsize) {
                for (int i = 0; i < this.colsize - tmpCols; i++) {
                    rowlist.add(rowlist.size(), "");
                }
            }
            try {
                operateRows(sheetIndex, rowlist);
            } catch (DataFormatException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            if (currentRow == this.titleRow) {
                this.colsize = rowlist.size();
            }
            rowlist.clear();
            currentRow++;
            currentCol = 0;
            preCol = 0;
        }
    }
}
Also used : XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) DataFormatException(com.cubrid.common.ui.cubrid.table.dialog.DataFormatException) SQLException(java.sql.SQLException) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) SQLException(java.sql.SQLException) SAXException(org.xml.sax.SAXException) DataFormatException(com.cubrid.common.ui.cubrid.table.dialog.DataFormatException)

Aggregations

DataFormatException (com.cubrid.common.ui.cubrid.table.dialog.DataFormatException)1 SQLException (java.sql.SQLException)1 XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)1 SAXException (org.xml.sax.SAXException)1