There is no direct method in the current source code:
This creates the style:
public HSSFCellStyle createCellStyle() { ... ExtendedFormatRecord xfr = workbook.createCellXF(); short index = (short) (getNumCellStyles() - 1); HSSFCellStyle style = new HSSFCellStyle(index, xfr, this); return style; }
from
public short getNumCellStyles() { return (short) workbook.getNumExFormats(); }
and (in InternalWorkbook)
public int getNumExFormats() { ... return numxfs; }
and with workbook.createCellXF () allowing:
public ExtendedFormatRecord createCellXF() { ExtendedFormatRecord xf = createExtendedFormat(); records.add(records.getXfpos()+1, xf); records.setXfpos( records.getXfpos() + 1 ); numxfs++; return xf; }
So from the HSSFWorkbook you can call:
InternalWorkbook getWorkbook() { return workbook; }
and then on the InternalWorkbook object:
public ExtendedFormatRecord getExFormatAt(int index) { int xfptr = records.getXfpos() - (numxfs - 1); xfptr += index; ExtendedFormatRecord retval = ( ExtendedFormatRecord ) records.get(xfptr); return retval; } public void removeExFormatRecord(ExtendedFormatRecord rec) { records.remove(rec);
So, to do this briefly, from the top book, something like this:
InternalWorkbook w = workbook.getWorkbook(); ExtendedFormatRecord record = w.getExFormatAt(index); w.removeExFormatRecord(record);
This is very terrible :)
source share