Search in sources :

Example 6 with SSTRecord

use of org.apache.poi.hssf.record.SSTRecord in project poi by apache.

the class InternalWorkbook method insertSST.

/**
     * use this function to add a Shared String Table to an existing sheet (say
     * generated by a different java api) without an sst....
     * @see #createExtendedSST()
     * @see org.apache.poi.hssf.record.SSTRecord
     */
public void insertSST() {
    LOG.log(DEBUG, "creating new SST via insertSST!");
    sst = new SSTRecord();
    records.add(records.size() - 1, createExtendedSST());
    records.add(records.size() - 2, sst);
}
Also used : SSTRecord(org.apache.poi.hssf.record.SSTRecord) ExtSSTRecord(org.apache.poi.hssf.record.ExtSSTRecord)

Example 7 with SSTRecord

use of org.apache.poi.hssf.record.SSTRecord in project poi by apache.

the class HSSFWorkbook method convertLabelRecords.

/**
      * This is basically a kludge to deal with the now obsolete Label records.  If
      * you have to read in a sheet that contains Label records, be aware that the rest
      * of the API doesn't deal with them, the low level structure only provides read-only
      * semi-immutable structures (the sets are there for interface conformance with NO
      * Implementation).  In short, you need to call this function passing it a reference
      * to the Workbook object.  All labels will be converted to LabelSST records and their
      * contained strings will be written to the Shared String table (SSTRecord) within
      * the Workbook.
      *
      * @param records a collection of sheet's records.
      * @param offset the offset to search at
      * @see org.apache.poi.hssf.record.LabelRecord
      * @see org.apache.poi.hssf.record.LabelSSTRecord
      * @see org.apache.poi.hssf.record.SSTRecord
      */
private void convertLabelRecords(List<Record> records, int offset) {
    if (log.check(POILogger.DEBUG)) {
        log.log(POILogger.DEBUG, "convertLabelRecords called");
    }
    for (int k = offset; k < records.size(); k++) {
        Record rec = records.get(k);
        if (rec.getSid() == LabelRecord.sid) {
            LabelRecord oldrec = (LabelRecord) rec;
            records.remove(k);
            LabelSSTRecord newrec = new LabelSSTRecord();
            int stringid = workbook.addSSTString(new UnicodeString(oldrec.getValue()));
            newrec.setRow(oldrec.getRow());
            newrec.setColumn(oldrec.getColumn());
            newrec.setXFIndex(oldrec.getXFIndex());
            newrec.setSSTIndex(stringid);
            records.add(k, newrec);
        }
    }
    if (log.check(POILogger.DEBUG)) {
        log.log(POILogger.DEBUG, "convertLabelRecords exit");
    }
}
Also used : UnicodeString(org.apache.poi.hssf.record.common.UnicodeString) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) RecalcIdRecord(org.apache.poi.hssf.record.RecalcIdRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) Record(org.apache.poi.hssf.record.Record) AbstractEscherHolderRecord(org.apache.poi.hssf.record.AbstractEscherHolderRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) BackupRecord(org.apache.poi.hssf.record.BackupRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord) LabelRecord(org.apache.poi.hssf.record.LabelRecord) FilePassRecord(org.apache.poi.hssf.record.FilePassRecord) FontRecord(org.apache.poi.hssf.record.FontRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) LabelRecord(org.apache.poi.hssf.record.LabelRecord) LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord)

Example 8 with SSTRecord

use of org.apache.poi.hssf.record.SSTRecord in project poi by apache.

the class TestLinkTable method testMissingExternSheetRecord_bug47001b.

/**
	 * This problem was visible in POI svn r763332
	 * when reading the workbook of attachment 23468 from bugzilla 47001
	 */
public void testMissingExternSheetRecord_bug47001b() {
    Record[] recs = { SupBookRecord.createAddInFunctions(), new SSTRecord() };
    List<Record> recList = Arrays.asList(recs);
    WorkbookRecordList wrl = new WorkbookRecordList();
    LinkTable lt;
    try {
        lt = new LinkTable(recList, 0, wrl, Collections.<String, NameCommentRecord>emptyMap());
    } catch (RuntimeException e) {
        if (e.getMessage().equals("Expected an EXTERNSHEET record but got (org.apache.poi.hssf.record.SSTRecord)")) {
            throw new AssertionFailedError("Identified bug 47001b");
        }
        throw e;
    }
    assertNotNull(lt);
}
Also used : Record(org.apache.poi.hssf.record.Record) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) ExternalNameRecord(org.apache.poi.hssf.record.ExternalNameRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) CountryRecord(org.apache.poi.hssf.record.CountryRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) AssertionFailedError(junit.framework.AssertionFailedError) SSTRecord(org.apache.poi.hssf.record.SSTRecord)

Aggregations

SSTRecord (org.apache.poi.hssf.record.SSTRecord)8 Record (org.apache.poi.hssf.record.Record)7 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)6 EOFRecord (org.apache.poi.hssf.record.EOFRecord)6 ExternSheetRecord (org.apache.poi.hssf.record.ExternSheetRecord)6 NameRecord (org.apache.poi.hssf.record.NameRecord)6 SupBookRecord (org.apache.poi.hssf.record.SupBookRecord)6 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)5 EscherRecord (org.apache.poi.ddf.EscherRecord)5 BOFRecord (org.apache.poi.hssf.record.BOFRecord)5 BackupRecord (org.apache.poi.hssf.record.BackupRecord)5 CountryRecord (org.apache.poi.hssf.record.CountryRecord)5 DrawingGroupRecord (org.apache.poi.hssf.record.DrawingGroupRecord)5 ExtSSTRecord (org.apache.poi.hssf.record.ExtSSTRecord)5 ExtendedFormatRecord (org.apache.poi.hssf.record.ExtendedFormatRecord)5 FilePassRecord (org.apache.poi.hssf.record.FilePassRecord)5 FontRecord (org.apache.poi.hssf.record.FontRecord)5 NameCommentRecord (org.apache.poi.hssf.record.NameCommentRecord)5 RecalcIdRecord (org.apache.poi.hssf.record.RecalcIdRecord)5 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)4