Không có phương pháp trực tiếp trong mã nguồn hiện tại:
Đây là cách phong cách được tạo ra :
public HSSFCellStyle createCellStyle()
{
...
ExtendedFormatRecord xfr = workbook.createCellXF();
short index = (short) (getNumCellStyles() - 1);
HSSFCellStyle style = new HSSFCellStyle(index, xfr, this);
return style;
}
với
public short getNumCellStyles()
{
return (short) workbook.getNumExFormats();
}
và (trong InternalWorkbook)
public int getNumExFormats() {
...
return numxfs;
}
và bằng sổ làm việc.createCellXF() giải quyết để:
public ExtendedFormatRecord createCellXF() {
ExtendedFormatRecord xf = createExtendedFormat();
records.add(records.getXfpos()+1, xf);
records.setXfpos(records.getXfpos() + 1);
numxfs++;
return xf;
}
Vì vậy, những gì có thể từ HSSFWorkbook, là để gọi:
InternalWorkbook getWorkbook() {
return workbook;
}
và sau đó trên đối tượng InternalWorkbook:
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--;
}
Vì vậy, để làm cho nó ngắn, từ bảng tính hàng đầu, như sau:
InternalWorkbook w = workbook.getWorkbook();
ExtendedFormatRecord record = w.getExFormatAt(index);
w.removeExFormatRecord(record);
Điều này tất cả đều rất kinh khủng :)
Có vẻ như nó nên thực hiện công việc ... nhưng việc chạy nó không thực sự làm gì cả! Tôi sẽ cố gắng gỡ lỗi lại sau. – AhHatem