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;
}
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;
}
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);
}
Aggregations