There is no direct method in the current source code:
This is how the style is created:
public HSSFCellStyle createCellStyle()
{
...
ExtendedFormatRecord xfr = workbook.createCellXF();
short index = (short) (getNumCellStyles() - 1);
HSSFCellStyle style = new HSSFCellStyle(index, xfr, this);
return style;
}
with
public short getNumCellStyles()
{
return (short) workbook.getNumExFormats();
}
and (in InternalWorkbook)
public int getNumExFormats() {
...
return numxfs;
}
and with the workbook.createCellXF() resolving to:
public ExtendedFormatRecord createCellXF() {
ExtendedFormatRecord xf = createExtendedFormat();
records.add(records.getXfpos()+1, xf);
records.setXfpos( records.getXfpos() + 1 );
numxfs++;
return xf;
}
So what is possible from the HSSFWorkbook, is to 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); // this updates XfPos for us
numxfs--;
}
So to make it short, from the top workbook, something like this:
InternalWorkbook w = workbook.getWorkbook();
ExtendedFormatRecord record = w.getExFormatAt(index);
w.removeExFormatRecord(record);
This is all very horrible :)