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

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

Introduction

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

Prototype

public UnicodeString getString(int id) 

Source Link

Document

Get a particular string by its index

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 w w w  .  java2s. co m
@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);
    }
}