* get the number of styles the workbook contains
* @return count of cell styles
*/
-
@Override
- public short getNumCellStyles()
+ public int getNumCellStyles()
{
- return (short) workbook.getNumExFormats();
+ return workbook.getNumExFormats();
}
/**
* @return HSSFCellStyle object at the index
*/
@Override
- public HSSFCellStyle getCellStyleAt(short idx)
+ public HSSFCellStyle getCellStyleAt(int idx)
{
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
- HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this);
+ HSSFCellStyle style = new HSSFCellStyle((short)idx, xfr, this);
return style;
}
*
* @return count of cell styles
*/
- short getNumCellStyles();
+ int getNumCellStyles();
/**
* Get the cell style object at the given index
* @param idx index within the set of styles (0-based)
* @return CellStyle object at the index
*/
- CellStyle getCellStyleAt(short idx);
+ CellStyle getCellStyleAt(int idx);
/**
* Write out this workbook to an Outputstream.
// index seems like what index the cellstyle is in the list of styles for a workbook.
// not good to compare on!
- short numberCellStyles = workbook.getNumCellStyles();
+ int numberCellStyles = workbook.getNumCellStyles();
- for (short i = 0; i < numberCellStyles; i++) {
+ for (int i = 0; i < numberCellStyles; i++) {
CellStyle wbStyle = workbook.getCellStyleAt(i);
Map<String, Object> wbStyleMap = getFormatProperties(wbStyle);
* @return count of cell styles
*/
@Override
- public short getNumCellStyles()
+ public int getNumCellStyles()
{
return _wb.getNumCellStyles();
}
* @return CellStyle object at the index
*/
@Override
- public CellStyle getCellStyleAt(short idx)
+ public CellStyle getCellStyleAt(int idx)
{
return _wb.getCellStyleAt(idx);
}
return pictures; //YK: should return Collections.unmodifiableList(pictures);
}
- /**
- * Get the cell style object at the given index
- *
- * @param idx index within the set of styles
- * @return XSSFCellStyle object at the index
- */
- @Override
- public XSSFCellStyle getCellStyleAt(short idx) {
- return getCellStyleAt(idx&0xffff);
- }
/**
* Get the cell style object at the given index
*
*
* @return count of cell styles
*/
- @Override
- public short getNumCellStyles() {
- return (short) (stylesSource).getNumCellStyles();
+ public int getNumCellStyles() {
+ return stylesSource.getNumCellStyles();
}
/**
XSSFCellStyle style = wb.createCellStyle();
assertEquals(i, style.getUIndex());
}
+ assertEquals(numStyles, wb.getNumCellStyles());
// avoid OOM in gump run
File file = XSSFTestDataSamples.writeOutAndClose(wb, "bug57880");
//Assume identical cell styles aren't consolidated
//If XSSFWorkbooks ever implicitly optimize/consolidate cell styles (such as when the workbook is written to disk)
//then this unit test should be updated
+ assertEquals(numStyles, wb.getNumCellStyles());
for (int i=1; i<numStyles; i++) {
XSSFCellStyle style = wb.getCellStyleAt(i);
assertNotNull(style);
}
public static void copyStyles(Workbook reference, Workbook target) {
- final short numberOfStyles = reference.getNumCellStyles();
+ final int numberOfStyles = reference.getNumCellStyles();
// don't copy default style (style index 0)
- for (short i = 1; i < numberOfStyles; i++) {
+ for (int i = 1; i < numberOfStyles; i++) {
final CellStyle referenceStyle = reference.getCellStyleAt(i);
final CellStyle targetStyle = target.createCellStyle();
targetStyle.cloneStyleFrom(referenceStyle);
public void getNumCellStyles() throws IOException{
XSSFWorkbook workbook = new XSSFWorkbook();
try {
- short i = workbook.getNumCellStyles();
//get default cellStyles
- assertEquals(1, i);
+ assertEquals(1, workbook.getNumCellStyles());
} finally {
workbook.close();
}
@Test
public void bug49751() throws Exception {
HSSFWorkbook wb = openSample("49751.xls");
- short numCellStyles = wb.getNumCellStyles();
+ int numCellStyles = wb.getNumCellStyles();
List<String> namedStyles = Arrays.asList(
"20% - Accent1", "20% - Accent2", "20% - Accent3", "20% - Accent4", "20% - Accent5",
"20% - Accent6", "40% - Accent1", "40% - Accent2", "40% - Accent3", "40% - Accent4",
"Neutral", "Note", "Output", "Title", "Total", "Warning Text");
List<String> collecteddStyles = new ArrayList<String>();
- for (short i = 0; i < numCellStyles; i++) {
+ for (int i = 0; i < numCellStyles; i++) {
HSSFCellStyle cellStyle = wb.getCellStyleAt(i);
String styleName = cellStyle.getUserStyleName();
if (styleName != null) {