}
ExtendedFormatRecord xf = book.getExFormatAt(cval.getXFIndex());
- setCellStyle(new HSSFCellStyle(( short ) cval.getXFIndex(), xf));
+ setCellStyle(new HSSFCellStyle(( short ) cval.getXFIndex(), xf, book));
}
/**
{
short styleIndex=record.getXFIndex();
ExtendedFormatRecord xf = book.getExFormatAt(styleIndex);
- return new HSSFCellStyle(styleIndex, xf);
+ return new HSSFCellStyle(styleIndex, xf, book);
}
/**
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
-import org.apache.poi.hssf.util.*;
+import org.apache.poi.hssf.util.HSSFColor;
/**
* High level representation of the style of a cell in a sheet of a workbook.
{
private ExtendedFormatRecord format = null;
private short index = 0;
+ private Workbook workbook = null;
/**
* general (normal) horizontal alignment
/** Creates new HSSFCellStyle why would you want to do this?? */
-
- protected HSSFCellStyle(short index, ExtendedFormatRecord rec)
+ protected HSSFCellStyle(short index, ExtendedFormatRecord rec, HSSFWorkbook workbook)
+ {
+ this(index, rec, workbook.getWorkbook());
+ }
+ protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook)
{
+ this.workbook = workbook;
this.index = index;
format = rec;
}
return format.getFormatIndex();
}
+ /**
+ * Get the contents of the format string, by looking up
+ * the DataFormat against the bound workbook
+ * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
+ */
+ public String getDataFormatString() {
+ HSSFDataFormat format = new HSSFDataFormat(workbook);
+
+ return format.getFormat(getDataFormat());
+ }
/**
* Get the contents of the format string, by looking up
* the DataFormat against the supplied workbook
public void setFont(HSSFFont font)
{
format.setIndentNotParentFont(true);
- short fontindex = font.getIndex();
+ short fontindex = ((HSSFFont) font).getIndex();
format.setFontIndex(fontindex);
}
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
*/
public HSSFFont getFont(HSSFWorkbook parentWorkbook) {
- return parentWorkbook.getFontAt(getFontIndex());
+ return ((HSSFWorkbook) parentWorkbook).getFontAt(getFontIndex());
}
/**
{
ExtendedFormatRecord xfr = workbook.createCellXF();
short index = (short) (getNumCellStyles() - 1);
- HSSFCellStyle style = new HSSFCellStyle(index, xfr);
+ HSSFCellStyle style = new HSSFCellStyle(index, xfr, this);
return style;
}
public HSSFCellStyle getCellStyleAt(short idx)
{
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
- HSSFCellStyle style = new HSSFCellStyle(idx, xfr);
+ HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this);
return style;
}