Example usage for org.apache.poi.hssf.record FormulaRecord getRow

List of usage examples for org.apache.poi.hssf.record FormulaRecord getRow

Introduction

In this page you can find the example usage for org.apache.poi.hssf.record FormulaRecord getRow.

Prototype

@Override
    public final int getRow() 

Source Link

Usage

From source file:XLS2CSVmra.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the
 *  CSV as the file is processed./*from w  w  w.j  av a2s.c  o m*/
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;
    case FormatRecord.sid:
        FormatRecord fr = (FormatRecord) record;
        customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
        break;
    case ExtendedFormatRecord.sid:
        ExtendedFormatRecord xr = (ExtendedFormatRecord) record;
        xfRecords.add(xr);
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;
    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            thisStr = '"' + formatNumberDateCell(frec, frec.getValue()) + '"';
        } else {
            // TODO: Output the formula string
            thisStr = '"' + frec.toString().replaceAll("\"", "\"\"") + '"';
        }
        break;
    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue().replaceAll("\"", "\"\"") + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString().replaceAll("\"", "\"\"") + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = '"' + formatNumberDateCell(numrec, numrec.getValue()) + '"';
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    //set the minColumns based on the first row (headers)
    if (thisRow == 0)
        minColumns = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(",\"\"");
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println();
    }
}

From source file:XLS2CSV.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the CSV as the
 * file is processed.//from   ww w.ja va2 s  .  c  o  m
 */
@SuppressWarnings("unchecked")
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            // their BOFRecords, and then knowing that we
            // process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            output.println();
            output.println(orderedBSRs[sheetIndex].getSheetname() + " [" + (sheetIndex + 1) + "]:");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue() + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(',');
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println();
    }
}

From source file:cn.sinobest.jzpt.minidemo.poidemo.example.XLS2CSVmra.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the
 *  CSV as the file is processed./*from w w  w  .j  a  v  a  2 s.c om*/
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            //  their BOFRecords, and then knowing that we
            //  process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            output.println();
            output.println(orderedBSRs[sheetIndex].getSheetname() + " [" + (sheetIndex + 1) + "]:");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue() + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;
        System.out.println(numrec.getSid());

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        //            if(HSSFDateUtil.isValidExcelDate(numrec.getValue())){
        System.out.println(HSSFDateUtil.isValidExcelDate(numrec.getValue()));

        //            }
        //            System.out.println("formatListener--------"+formatListener.getFormatString(1));
        //            System.out.println("thisStr----------"+thisStr);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(',');
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println();
    }
}

From source file:com.bayareasoftware.chartengine.ds.util.XLS2Data.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the CSV as the
 * file is processed./*from w w w .  java  2s  . co m*/
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    //p("looking at " + record.getClass().getName() + " sid=0x" + Integer.toHexString(record.getSid()));
    if ((record.getSid() != BoundSheetRecord.sid && record.getSid() != BOFRecord.sid)
            && currentSheetName != null && this.requiredSheetName != null
            && !this.requiredSheetName.equals(currentSheetName)) {
        return;
    }
    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            // their BOFRecords, and then knowing that we
            // process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            //output.println();
            startNewSheet();
            currentSheetName = orderedBSRs[sheetIndex].getSheetname();
            //System.err.println("got sheet name '" + currentSheetName + "' required='"
            //      + this.requiredSheetName + "'");
            /*if (requiredSheetName == null) {
            startNewRow();
            //output.println(orderedBSRs[sheetIndex].getSheetname() + " ["
            //+ (sheetIndex + 1) + "]:");
            appendCell(currentSheetName + " ["
                    + (sheetIndex + 1) + "]:");
            startNewRow();
            }
            */
        } else if (br.getType() == BOFRecord.TYPE_CHART) {
            //p("got chart");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = "" + frec.getValue();
                //thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        //thisStr = '"' + lrec.getValue() + '"';
        thisStr = lrec.getValue();
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            //thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex())
            //      .toString() + '"';
            thisStr = sstRecord.getString(lsrec.getSSTIndex()).toString();
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO - NoteRecord (" + thisRow + "," + thisColumn + "))" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO - RKRecord (" + thisRow + "," + thisColumn + "))" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        appendCell(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        //output.println();
        startNewRow();
    }
}

From source file:com.bstek.dorado.importer.policy.impl.XLS2CSV.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the CSV as the
 * file is processed.//  w  w  w  . ja va 2 s  .c  om
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            // their BOFRecords, and then knowing that we
            // process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            output.println();
            output.println(orderedBSRs[sheetIndex].getSheetname() + " [" + (sheetIndex + 1) + "]:");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue() + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(',');
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println();
    }
}

From source file:com.epac.java.converter.ms2text.XLS2CSVmra.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the
 *  CSV as the file is processed.//from  w w  w . j  a  va  2s.c o  m
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            //  their BOFRecords, and then knowing that we
            //  process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            output.println();
            output.println(orderedBSRs[sheetIndex].getSheetname() + " [" + (sheetIndex + 1) + "]:");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue() + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(',');
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println();
    }
}

From source file:com.googlecode.sqlsheet.stream.XlsSheetIterator.java

License:Apache License

/**
 * Main HSSFListener method, processes events
 *//*  w  w w. j av  a2 s . c  o m*/
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    CellValueHolder thisCellValue = new CellValueHolder();

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }
            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            //  their BOFRecords, and then knowing that we
            //  postConstruct BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            inRequiredSheet = getSheetName().equalsIgnoreCase(orderedBSRs[sheetIndex].getSheetname())
                    || ("\"" + orderedBSRs[sheetIndex].getSheetname() + "\"").equalsIgnoreCase(getSheetName());
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisCellValue.stringValue = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;
        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisCellValue.stringValue = "";
        break;
    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;
        thisRow = frec.getRow();
        thisColumn = frec.getColumn();
        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisCellValue.stringValue = formatListener.formatNumberDateCell(frec);
                thisCellValue.doubleValue = frec.getValue();
                thisCellValue.dateValue = convertDateValue(frec.getValue(), formatListener.getFormatIndex(frec),
                        formatListener.getFormatString(frec));
            }
        } else {
            thisCellValue.stringValue = HSSFFormulaParser.toFormulaString(stubWorkbook,
                    frec.getParsedExpression());
            thisCellValue.doubleValue = frec.getValue();
            thisCellValue.dateValue = convertDateValue(frec.getValue(), formatListener.getFormatIndex(frec),
                    formatListener.getFormatString(frec));
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisCellValue.stringValue = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;
        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisCellValue.stringValue = lrec.getValue();
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;
        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisCellValue.stringValue = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisCellValue.stringValue = sstRecord.getString(lsrec.getSSTIndex()).toString();
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;
        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisCellValue.stringValue = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;
        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();
        // Format
        thisCellValue.stringValue = formatListener.formatNumberDateCell(numrec);
        thisCellValue.doubleValue = numrec.getValue();
        thisCellValue.dateValue = convertDateValue(numrec.getValue(), formatListener.getFormatIndex(numrec),
                formatListener.getFormatString(numrec));
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;
        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisCellValue.stringValue = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }
    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }
    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisCellValue.stringValue = "";
    }
    // If we got something to print out, do so
    if (thisCellValue.stringValue != null) {
        //If we are on the first row - fill column names
        if (getCurrentSheetRowIndex().equals(0L) && inRequiredSheet) {
            getColumns().add(thisCellValue);
        } else if (inRequiredSheet) {
            addCurrentRowValue(thisCellValue);
        }
    }
    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;
    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // We're onto a new row
        lastColumnNumber = -1;
        // End the row
        setCurrentSheetRowIndex(getCurrentSheetRowIndex() + 1);
    }
}

From source file:com.googlecode.sqlsheet.XLS2CSVmra.java

License:Apache License

/**
 * Main HSSFListener method, processes events, and outputs the
 *  CSV as the file is processed.//  w ww. j a  v a 2s . c o  m
 */
public void processRecord(Record record) {
    int thisRow = -1;
    int thisColumn = -1;
    String thisStr = null;

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        boundSheetRecords.add(record);
        break;
    case BOFRecord.sid:
        BOFRecord br = (BOFRecord) record;
        if (br.getType() == BOFRecord.TYPE_WORKSHEET) {
            // Create sub workbook if required
            if (workbookBuildingListener != null && stubWorkbook == null) {
                stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
            }

            // Output the worksheet name
            // Works by ordering the BSRs by the location of
            //  their BOFRecords, and then knowing that we
            //  process BOFRecords in byte offset order
            sheetIndex++;
            if (orderedBSRs == null) {
                orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
            }
            currentSheetName = orderedBSRs[sheetIndex].getSheetname();
            output.println();
            output.println(orderedBSRs[sheetIndex].getSheetname() + " [" + (sheetIndex + 1) + "]:");
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord brec = (BlankRecord) record;

        thisRow = brec.getRow();
        thisColumn = brec.getColumn();
        thisStr = "";
        break;
    case BoolErrRecord.sid:
        BoolErrRecord berec = (BoolErrRecord) record;

        thisRow = berec.getRow();
        thisColumn = berec.getColumn();
        thisStr = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;

        thisRow = frec.getRow();
        thisColumn = frec.getColumn();

        if (outputFormulaValues) {
            if (Double.isNaN(frec.getValue())) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringRecord = true;
                nextRow = frec.getRow();
                nextColumn = frec.getColumn();
            } else {
                thisStr = formatListener.formatNumberDateCell(frec);
            }
        } else {
            thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
        }
        break;
    case StringRecord.sid:
        if (outputNextStringRecord) {
            // String for formula
            StringRecord srec = (StringRecord) record;
            thisStr = srec.getString();
            thisRow = nextRow;
            thisColumn = nextColumn;
            outputNextStringRecord = false;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;

        thisRow = lrec.getRow();
        thisColumn = lrec.getColumn();
        thisStr = '"' + lrec.getValue() + '"';
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;

        thisRow = lsrec.getRow();
        thisColumn = lsrec.getColumn();
        if (sstRecord == null) {
            thisStr = '"' + "(No SST Record, can't identify string)" + '"';
        } else {
            thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
        }
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;

        thisRow = nrec.getRow();
        thisColumn = nrec.getColumn();
        // TODO: Find object to match nrec.getShapeId()
        thisStr = '"' + "(TODO)" + '"';
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;

        thisRow = numrec.getRow();
        thisColumn = numrec.getColumn();

        // Format
        thisStr = formatListener.formatNumberDateCell(numrec);
        break;
    case RKRecord.sid:
        RKRecord rkrec = (RKRecord) record;

        thisRow = rkrec.getRow();
        thisColumn = rkrec.getColumn();
        thisStr = '"' + "(TODO)" + '"';
        break;
    default:
        break;
    }

    // Handle new row
    if (thisRow != -1 && thisRow != lastRowNumber) {
        lastColumnNumber = -1;
    }

    // Handle missing column
    if (record instanceof MissingCellDummyRecord) {
        MissingCellDummyRecord mc = (MissingCellDummyRecord) record;
        thisRow = mc.getRow();
        thisColumn = mc.getColumn();
        thisStr = "";
    }

    // If we got something to print out, do so
    if (thisStr != null) {
        if (thisColumn > 0) {
            output.print(',');
        }
        output.print(thisStr);
    }

    // Update column and row count
    if (thisRow > -1)
        lastRowNumber = thisRow;
    if (thisColumn > -1)
        lastColumnNumber = thisColumn;

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        // Print out any missing commas if needed
        if (minColumns > 0) {
            // Columns are 0 based
            if (lastColumnNumber == -1) {
                lastColumnNumber = 0;
            }
            for (int i = lastColumnNumber; i < (minColumns); i++) {
                output.print(',');
            }
        }

        // We're onto a new row
        lastColumnNumber = -1;

        // End the row
        output.println("--> " + currentSheetName);
    }
}

From source file:com.sonicle.webtop.core.io.input.XlsPartsProcessorOLD.java

License:Open Source License

@Override
public void processRecord(Record record) {
    cellValue = null;//from w  w w . ja  v a2 s . c o  m

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        BoundSheetRecord bsr = (BoundSheetRecord) record;
        if (!sheetFound) {
            if (StringUtils.equals(bsr.getSheetname(), sheetName)) {
                sheetFound = true;
                columnNames = new LinkedHashMap<>();
                columnIndexes = new HashMap<>();
            }
        } else {
            close();
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord br = (BlankRecord) record;
        row = br.getRow();
        col = br.getColumn();
        cellValue = "";
        break;

    case BoolErrRecord.sid:
        BoolErrRecord ber = (BoolErrRecord) record;
        row = ber.getRow();
        col = ber.getColumn();
        cellValue = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord fr = (FormulaRecord) record;
        row = fr.getRow();
        col = fr.getColumn();
        if (Double.isNaN(fr.getValue())) {
            // Formula result is a string that is stored in the next record!
            findNextStringRecord = true;
            nextRow = fr.getRow();
            nextCol = fr.getColumn();
            cellValue = null;
        } else {
            cellValue = formatTrackingListener.formatNumberDateCell(fr);
        }
        break;

    case StringRecord.sid:
        if (findNextStringRecord) {
            // String for formula 
            StringRecord sr = (StringRecord) record;
            cellValue = sr.getString();
            row = nextRow;
            col = nextCol;
            // Resets markers...
            findNextStringRecord = false;
            nextRow = -1;
            nextCol = -1;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lr = (LabelRecord) record;
        row = lr.getRow();
        col = lr.getColumn();
        cellValue = lr.getValue();
        break;

    case LabelSSTRecord.sid:
        LabelSSTRecord lsstr = (LabelSSTRecord) record;
        row = lsstr.getRow();
        col = lsstr.getColumn();
        if (sstRecord == null) {
            cellValue = "#ERROR(undefined string)";
        } else {
            cellValue = sstRecord.getString(lsstr.getSSTIndex()).toString();
        }
        break;

    case NoteRecord.sid:
        NoteRecord nr = (NoteRecord) record;
        row = nr.getRow();
        col = nr.getColumn();
        // TODO: Find object to match nrec.getShapeId() 
        cellValue = "#ERROR(TODO)";
        break;

    case NumberRecord.sid:
        NumberRecord rn = (NumberRecord) record;
        row = rn.getRow();
        col = rn.getColumn();
        cellValue = formatTrackingListener.formatNumberDateCell(rn);
        break;

    case RKRecord.sid:
        RKRecord rkr = (RKRecord) record;
        row = rkr.getRow();
        col = rkr.getColumn();
        cellValue = "#ERROR(TODO)";
        break;

    default:
        cellValue = null;
    }

    if (row == headersRow) {
        String cellReference = CellReference.convertNumToColString(col);
        String name = (headersRow == firstDataRow) ? cellReference
                : StringUtils.defaultIfBlank(cellValue, cellReference);
        columnNames.put(name.toLowerCase(), name);
        columnIndexes.put(name, col);
    }
}

From source file:com.sonicle.webtop.core.io.input.XlsRecordsProcessor.java

License:Open Source License

@Override
public void processRecord(Record record) {
    int thisRow = -1;
    int thisCol = -1;
    cellValue = null;/*from www.j a va2s  .co  m*/

    switch (record.getSid()) {
    case BoundSheetRecord.sid:
        BoundSheetRecord bsr = (BoundSheetRecord) record;
        if (!sheetFound) {
            if (StringUtils.equals(bsr.getSheetname(), sheetName)) {
                sheetFound = true;
                columnNames = new LinkedHashMap<>();
                columnIndexes = new HashMap<>();
            }
        } else {
            close();
        }
        break;

    case SSTRecord.sid:
        sstRecord = (SSTRecord) record;
        break;

    case BlankRecord.sid:
        BlankRecord br = (BlankRecord) record;
        thisRow = br.getRow();
        thisCol = br.getColumn();
        cellValue = "";
        break;

    case BoolErrRecord.sid:
        BoolErrRecord ber = (BoolErrRecord) record;
        thisRow = ber.getRow();
        thisCol = ber.getColumn();
        cellValue = "";
        break;

    case FormulaRecord.sid:
        FormulaRecord fr = (FormulaRecord) record;
        thisRow = fr.getRow();
        thisCol = fr.getColumn();
        if (Double.isNaN(fr.getValue())) {
            // Formula result is a string that is stored in the next record!
            findNextStringRecord = true;
            nextRow = fr.getRow();
            nextCol = fr.getColumn();
            cellValue = null;
        } else {
            cellValue = formatTrackingListener.formatNumberDateCell(fr);
        }
        break;

    case StringRecord.sid:
        if (findNextStringRecord) {
            // String for formula 
            StringRecord sr = (StringRecord) record;
            cellValue = sr.getString();
            thisRow = nextRow;
            thisCol = nextCol;
            // Resets markers...
            findNextStringRecord = false;
            nextRow = -1;
            nextCol = -1;
        }
        break;

    case LabelRecord.sid:
        LabelRecord lr = (LabelRecord) record;
        thisRow = lr.getRow();
        thisCol = lr.getColumn();
        cellValue = lr.getValue();
        break;

    case LabelSSTRecord.sid:
        LabelSSTRecord lsstr = (LabelSSTRecord) record;
        thisRow = lsstr.getRow();
        thisCol = lsstr.getColumn();
        if (sstRecord == null) {
            cellValue = "#ERROR(undefined string)";
        } else {
            cellValue = sstRecord.getString(lsstr.getSSTIndex()).toString();
        }
        break;

    case NoteRecord.sid:
        NoteRecord nr = (NoteRecord) record;
        thisRow = nr.getRow();
        thisCol = nr.getColumn();
        // TODO: Find object to match nrec.getShapeId() 
        cellValue = "#ERROR(TODO)";
        break;

    case NumberRecord.sid:
        NumberRecord rn = (NumberRecord) record;
        thisRow = rn.getRow();
        thisCol = rn.getColumn();
        cellValue = formatTrackingListener.formatNumberDateCell(rn);
        break;

    case RKRecord.sid:
        RKRecord rkr = (RKRecord) record;
        thisRow = rkr.getRow();
        thisCol = rkr.getColumn();
        cellValue = "#ERROR(TODO)";
        break;

    default:
        cellValue = null;
    }

    // Handle new row
    if ((thisRow != -1) && (thisRow != row)) {
        row = -1;
        isNewRow = true;
    } else {
        isNewRow = false;
    }
    if (thisRow > -1)
        row = thisRow;
    if (thisCol > -1)
        col = thisCol;
    isInRange = ((row >= firstDataRow) && ((lastDataRow == -1) || (row <= lastDataRow)));

    // Handle end of row
    if (record instanceof LastCellOfRowDummyRecord) {
        isDummyEndRow = true;
        col = -1; // We're nearly onto a new row
    } else {
        isDummyEndRow = false;
    }

    if (!isDummyEndRow && (row == headersRow)) {
        String cellReference = CellReference.convertNumToColString(col);
        String name = (headersRow == firstDataRow) ? cellReference
                : StringUtils.defaultIfBlank(cellValue, cellReference);
        columnNames.put(name.toLowerCase(), name);
        columnIndexes.put(name, col);
    }
}