}
/**
- * @deprecated (Sep 2008) use {@link #setColWidth(int, int)}
+ * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)}
*/
public void setColumnWidth(short columnIndex, short width) {
- setColWidth(columnIndex & 0xFFFF, width & 0xFFFF);
+ setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF);
}
/**
- * @deprecated (Sep 2008) use {@link #getColWidth(int)}
+ * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
*/
public short getColumnWidth(short columnIndex) {
- return (short)getColWidth(columnIndex & 0xFFFF);
+ return (short)getColumnWidth(columnIndex & 0xFFFF);
}
/**
- * @deprecated (Sep 2008) use {@link #getDefaultColWidth()}
- */
- public short getDefaultColumnWidth() {
- return (short) getDefaultColWidth();
- }
- /**
- * @deprecated (Sep 2008) use {@link #setDefaultColWidth(int)}
+ * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)}
*/
public void setDefaultColumnWidth(short width) {
- setDefaultColWidth(width & 0xFFFF);
+ setDefaultColumnWidth(width & 0xFFFF);
}
/**
* @param columnIndex - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width
*/
- public void setColWidth(int columnIndex, int width) {
+ public void setColumnWidth(int columnIndex, int width) {
sheet.setColumnWidth(columnIndex, width);
}
* @param columnIndex - the column to set (0-based)
* @return width - the width in units of 1/256th of a character width
*/
- public int getColWidth(int columnIndex) {
+ public int getColumnWidth(int columnIndex) {
return sheet.getColumnWidth(columnIndex);
}
* characters
* @return default column width
*/
- public int getDefaultColWidth() {
+ public int getDefaultColumnWidth() {
return sheet.getDefaultColumnWidth();
}
/**
* characters
* @param width default column width
*/
- public void setDefaultColWidth(int width) {
+ public void setDefaultColumnWidth(int width) {
sheet.setDefaultColumnWidth(width);
}
// autoSize the first column and check its size before the merged region (1,0,1,1) is set:
// it has to be based on the 2nd row width
sheet.autoSizeColumn((short)0);
- assertTrue("Column autosized with only one row: wrong width", sheet.getColWidth(0) >= minWithRow1And2);
- assertTrue("Column autosized with only one row: wrong width", sheet.getColWidth(0) <= maxWithRow1And2);
+ assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) >= minWithRow1And2);
+ assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) <= maxWithRow1And2);
//create a region over the 2nd row and auto size the first column
sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
// check that the autoSized column width has ignored the 2nd row
// because it is included in a merged region (Excel like behavior)
HSSFSheet sheet2 = wb2.getSheet(sheetName);
- assertTrue(sheet2.getColWidth(0) >= minWithRow1Only);
- assertTrue(sheet2.getColWidth(0) <= maxWithRow1Only);
+ assertTrue(sheet2.getColumnWidth(0) >= minWithRow1Only);
+ assertTrue(sheet2.getColumnWidth(0) <= maxWithRow1Only);
// remove the 2nd row merged region and check that the 2nd row value is used to the autoSizeColumn width
sheet2.removeMergedRegion(1);
sheet2.autoSizeColumn((short)0);
HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
HSSFSheet sheet3 = wb3.getSheet(sheetName);
- assertTrue(sheet3.getColWidth(0) >= minWithRow1And2);
- assertTrue(sheet3.getColWidth(0) <= maxWithRow1And2);
+ assertTrue(sheet3.getColumnWidth(0) >= minWithRow1And2);
+ assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
}
/**
HSSFSheet sh = wb.getSheetAt(0);
for (char i = 'A'; i <= 'S'; i++) {
int idx = i - 'A';
- int w = sh.getColWidth(idx);
+ int w = sh.getColumnWidth(idx);
assertEquals(ref[idx], w);
}
//the second sheet doesn't have overridden column widths
sh = wb.getSheetAt(1);
- int def_width = sh.getDefaultColWidth();
+ int def_width = sh.getDefaultColumnWidth();
for (char i = 'A'; i <= 'S'; i++) {
int idx = i - 'A';
- int w = sh.getColWidth(idx);
+ int w = sh.getColumnWidth(idx);
//getDefaultColumnWidth returns width measured in characters
//getColumnWidth returns width measured in 1/256th units
assertEquals(def_width*256, w);
//test new workbook
wb = new HSSFWorkbook();
sh = wb.createSheet();
- sh.setDefaultColWidth(10);
- assertEquals(10, sh.getDefaultColWidth());
- assertEquals(256*10, sh.getColWidth(0));
- assertEquals(256*10, sh.getColWidth(1));
- assertEquals(256*10, sh.getColWidth(2));
+ sh.setDefaultColumnWidth(10);
+ assertEquals(10, sh.getDefaultColumnWidth());
+ assertEquals(256*10, sh.getColumnWidth(0));
+ assertEquals(256*10, sh.getColumnWidth(1));
+ assertEquals(256*10, sh.getColumnWidth(2));
for (char i = 'D'; i <= 'F'; i++) {
short w = (256*12);
- sh.setColWidth(i, w);
- assertEquals(w, sh.getColWidth(i));
+ sh.setColumnWidth(i, w);
+ assertEquals(w, sh.getColumnWidth(i));
}
//serialize and read again
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
sh = wb.getSheetAt(0);
- assertEquals(10, sh.getDefaultColWidth());
+ assertEquals(10, sh.getDefaultColumnWidth());
//columns A-C have default width
- assertEquals(256*10, sh.getColWidth(0));
- assertEquals(256*10, sh.getColWidth(1));
- assertEquals(256*10, sh.getColWidth(2));
+ assertEquals(256*10, sh.getColumnWidth(0));
+ assertEquals(256*10, sh.getColumnWidth(1));
+ assertEquals(256*10, sh.getColumnWidth(2));
//columns D-F have custom width
for (char i = 'D'; i <= 'F'; i++) {
short w = (256*12);
- assertEquals(w, sh.getColWidth(i));
+ assertEquals(w, sh.getColumnWidth(i));
}
// check for 16-bit signed/unsigned error:
- sh.setColWidth(0, 40000);
- assertEquals(40000, sh.getColWidth(0));
+ sh.setColumnWidth(0, 40000);
+ assertEquals(40000, sh.getColumnWidth(0));
}
/**