Search in sources :

Example 1 with StyleRecord

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

the class InternalWorkbook method createStyle.

/**
     * Creates a StyleRecord object
     * @param id        the number of the style record to create (meaning its position in
     *                  a file as MS Excel would create it.
     */
private static StyleRecord createStyle(int id) {
    // we'll need multiple editions
    final int[][] mappings = { { 0x010, 3 }, { 0x011, 6 }, { 0x012, 4 }, { 0x013, 7 }, { 0x000, 0 }, { 0x014, 5 } };
    if (id < 0 || id >= mappings.length) {
        throw new IllegalArgumentException("Unexpected style id " + id);
    }
    StyleRecord retval = new StyleRecord();
    retval.setOutlineStyleLevel((byte) 0xffffffff);
    retval.setXFIndex(mappings[id][0]);
    retval.setBuiltinStyle(mappings[id][1]);
    return retval;
}
Also used : StyleRecord(org.apache.poi.hssf.record.StyleRecord)

Example 2 with StyleRecord

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

the class InternalWorkbook method createStyleRecord.

/**
     * Creates a new StyleRecord, for the given Extended
     *  Format index, and adds it onto the end of the
     *  records collection
     *
     * @param xfIndex the extended format index
     *
     * @return a new StyleRecord
     */
public StyleRecord createStyleRecord(int xfIndex) {
    // Style records always follow after
    //  the ExtendedFormat records
    StyleRecord newSR = new StyleRecord();
    newSR.setXFIndex(xfIndex);
    // Find the spot
    int addAt = -1;
    for (int i = records.getXfpos(); i < records.size() && addAt == -1; i++) {
        Record r = records.get(i);
        if (r instanceof ExtendedFormatRecord || r instanceof StyleRecord) {
        // Keep going
        } else {
            addAt = i;
        }
    }
    if (addAt == -1) {
        throw new IllegalStateException("No XF Records found!");
    }
    records.add(addAt, newSR);
    return newSR;
}
Also used : ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) StyleRecord(org.apache.poi.hssf.record.StyleRecord) WindowProtectRecord(org.apache.poi.hssf.record.WindowProtectRecord) PasswordRev4Record(org.apache.poi.hssf.record.PasswordRev4Record) DateWindow1904Record(org.apache.poi.hssf.record.DateWindow1904Record) FormatRecord(org.apache.poi.hssf.record.FormatRecord) BookBoolRecord(org.apache.poi.hssf.record.BookBoolRecord) StyleRecord(org.apache.poi.hssf.record.StyleRecord) RecalcIdRecord(org.apache.poi.hssf.record.RecalcIdRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) HideObjRecord(org.apache.poi.hssf.record.HideObjRecord) Record(org.apache.poi.hssf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) ProtectionRev4Record(org.apache.poi.hssf.record.ProtectionRev4Record) EOFRecord(org.apache.poi.hssf.record.EOFRecord) MMSRecord(org.apache.poi.hssf.record.MMSRecord) PrecisionRecord(org.apache.poi.hssf.record.PrecisionRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) CountryRecord(org.apache.poi.hssf.record.CountryRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) FnGroupCountRecord(org.apache.poi.hssf.record.FnGroupCountRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) BackupRecord(org.apache.poi.hssf.record.BackupRecord) EscherSplitMenuColorsRecord(org.apache.poi.ddf.EscherSplitMenuColorsRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) WriteAccessRecord(org.apache.poi.hssf.record.WriteAccessRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) CodepageRecord(org.apache.poi.hssf.record.CodepageRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) FilePassRecord(org.apache.poi.hssf.record.FilePassRecord) FontRecord(org.apache.poi.hssf.record.FontRecord) UseSelFSRecord(org.apache.poi.hssf.record.UseSelFSRecord) WindowOneRecord(org.apache.poi.hssf.record.WindowOneRecord) WriteProtectRecord(org.apache.poi.hssf.record.WriteProtectRecord) ProtectRecord(org.apache.poi.hssf.record.ProtectRecord) InterfaceHdrRecord(org.apache.poi.hssf.record.InterfaceHdrRecord) DSFRecord(org.apache.poi.hssf.record.DSFRecord) InterfaceEndRecord(org.apache.poi.hssf.record.InterfaceEndRecord) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) PasswordRecord(org.apache.poi.hssf.record.PasswordRecord) PaletteRecord(org.apache.poi.hssf.record.PaletteRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord) ExtSSTRecord(org.apache.poi.hssf.record.ExtSSTRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) FileSharingRecord(org.apache.poi.hssf.record.FileSharingRecord) RefreshAllRecord(org.apache.poi.hssf.record.RefreshAllRecord)

Example 3 with StyleRecord

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

the class HSSFCellStyle method setUserStyleName.

/**
     * Sets the name of the user defined style.
     * Will complain if you try this on a built in style.
     */
public void setUserStyleName(String styleName) {
    StyleRecord sr = _workbook.getStyleRecord(_index);
    if (sr == null) {
        sr = _workbook.createStyleRecord(_index);
    }
    //  only 20 and below really need to be
    if (sr.isBuiltin() && _index <= 20) {
        throw new IllegalArgumentException("Unable to set user specified style names for built in styles!");
    }
    sr.setName(styleName);
}
Also used : StyleRecord(org.apache.poi.hssf.record.StyleRecord)

Aggregations

StyleRecord (org.apache.poi.hssf.record.StyleRecord)3 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)1 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)1 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)1 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)1 EscherSplitMenuColorsRecord (org.apache.poi.ddf.EscherSplitMenuColorsRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BackupRecord (org.apache.poi.hssf.record.BackupRecord)1 BookBoolRecord (org.apache.poi.hssf.record.BookBoolRecord)1 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)1 CodepageRecord (org.apache.poi.hssf.record.CodepageRecord)1 CountryRecord (org.apache.poi.hssf.record.CountryRecord)1 DSFRecord (org.apache.poi.hssf.record.DSFRecord)1 DateWindow1904Record (org.apache.poi.hssf.record.DateWindow1904Record)1 DrawingGroupRecord (org.apache.poi.hssf.record.DrawingGroupRecord)1 EOFRecord (org.apache.poi.hssf.record.EOFRecord)1 ExtSSTRecord (org.apache.poi.hssf.record.ExtSSTRecord)1