Example usage for org.apache.poi.hssf.record SSTRecord getNumUniqueStrings

List of usage examples for org.apache.poi.hssf.record SSTRecord getNumUniqueStrings

Introduction

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

Prototype

public int getNumUniqueStrings() 

Source Link

Usage

From source file:org.jab.docsearch.converters.ExcelListener.java

License:Open Source License

/**
 * This method listens for incoming records and handles them as required.
 *
 * @param record  The record that was found while reading.
 *///from ww w  . jav a  2 s  .c om
@Override
public void processRecord(Record record) {
    try {
        switch (record.getSid()) {
        case NumberRecord.sid: {
            NumberRecord numrec = (NumberRecord) record;

            excelText.append(numrec.getValue());
            excelText.append('\n');

            break;
        }
        // SSTRecords store a array of unique strings used in Excel
        case SSTRecord.sid: {
            SSTRecord sstrec = (SSTRecord) record;

            for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
                excelText.append(sstrec.getString(k));
                excelText.append('\n');
            }

            break;
        }
        }
    } catch (Exception e) {
        log.error("processRecords() failed for Excel file", e);
    }
}