--- HSSFCell.java Fri Sep 19 04:19:58 2008 700026 +++ HSSFCell.java Mon Sep 29 18:23:05 2008 @@ -72,2 +72 @@ -public final class HSSFCell { - +public class HSSFCell { @@ -97,0 +97,63 @@ +// /** +// * Creates new Cell - Should only be called by HSSFRow. This creates a cell +// * from scratch. +// *
+// * When the cell is initially created it is set to CELL_TYPE_BLANK. Cell types +// * can be changed/overwritten by calling setCellValue with the appropriate +// * type as a parameter although conversions from one type to another may be +// * prohibited. +// * +// * @param book - Workbook record of the workbook containing this cell +// * @param sheet - Sheet record of the sheet containing this cell +// * @param row - the row of this cell +// * @param col - the column for this cell +// * +// * @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short) +// */ +// protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col) +// { +// this (book, sheet, row, col, CELL_TYPE_BLANK); +//// checkBounds(col); +//// stringValue = null; +//// this.book = book; +//// this.sheet = sheet; +//// +//// // Relying on the fact that by default the cellType is set to 0 which +//// // is different to CELL_TYPE_BLANK hence the following method call correctly +//// // creates a new blank cell. +//// short xfindex = sheet.getSheet().getXFIndexForColAt(col); +//// setCellType(CELL_TYPE_BLANK, false, row, col,xfindex); +// } + public HSSFSheet getSheet() { + return sheet; + } + public HSSFWorkbook getWorkbook() + { + return this.book; + } + +// /** +// * Creates new Cell - Should only be called by HSSFRow. This creates a cell +// * from scratch. +// * +// * @param book - Workbook record of the workbook containing this cell +// * @param sheet - Sheet record of the sheet containing this cell +// * @param row - the row of this cell +// * @param col - the column for this cell +// * @param type - CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BLANK, +// * CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR +// * Type of cell +// * @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short,int) +// */ +// protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col, +// int type) +// { +// checkBounds(col); +// cellType = -1; // Force 'setCellType' to create a first Record +// stringValue = null; +// this.book = book; +// this.sheet = sheet; +// +// short xfindex = sheet.getSheet().getXFIndexForColAt(col); +// setCellType(type,false,row,col,xfindex); +// } @@ -99,7 +160,0 @@ - * Creates new Cell - Should only be called by HSSFRow. This creates a cell - * from scratch. - *
- * When the cell is initially created it is set to CELL_TYPE_BLANK. Cell types - * can be changed/overwritten by calling setCellValue with the appropriate - * type as a parameter although conversions from one type to another may be - * prohibited. @@ -107,4 +162,5 @@ - * @param book - Workbook record of the workbook containing this cell - * @param sheet - Sheet record of the sheet containing this cell - * @param row - the row of this cell - * @param col - the column for this cell + * You can now also create a new HSSFCell with this public constructor, + * not having to use HSSFRow.createCell. + * This makes it possible to derive classes from HSSFCell + * (it is no longer final) and to construct objects of the derived + * classes which can be used like the original ones. @@ -112 +168,2 @@ - * @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short) + * @param hrow HSSFRow, in which the cell is to be created + * @param col Column index of the cell @@ -114 +171 @@ - protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col) + public HSSFCell(HSSFRow hrow, int col) @@ -116,10 +173 @@ - checkBounds(col); - stringValue = null; - this.book = book; - this.sheet = sheet; - - // Relying on the fact that by default the cellType is set to 0 which - // is different to CELL_TYPE_BLANK hence the following method call correctly - // creates a new blank cell. - short xfindex = sheet.getSheet().getXFIndexForColAt(col); - setCellType(CELL_TYPE_BLANK, false, row, col,xfindex); + this (hrow, col, CELL_TYPE_BLANK); @@ -127,3 +174,0 @@ - public HSSFSheet getSheet() { - return sheet; - } @@ -132,2 +176,0 @@ - * Creates new Cell - Should only be called by HSSFRow. This creates a cell - * from scratch. @@ -135,5 +178,9 @@ - * @param book - Workbook record of the workbook containing this cell - * @param sheet - Sheet record of the sheet containing this cell - * @param row - the row of this cell - * @param col - the column for this cell - * @param type - CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BLANK, + * You can now also create a new HSSFCell with this public constructor, + * not having to use HSSFRow.createCell. + * This makes it possible to derive classes from HSSFCell + * (it is no longer final) and to construct objects of the derived + * classes which can be used like the original ones. + * + * @param hrow HSSFRow, in which the cell is to be created + * @param col Column index of the cell + * @param type CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BLANK, @@ -141,2 +187,0 @@ - * Type of cell - * @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short,int) @@ -144,2 +189 @@ - protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col, - int type) + public HSSFCell(HSSFRow hrow, int col, int type) @@ -150,2 +194,3 @@ - this.book = book; - this.sheet = sheet; + HSSFRow.BookNSheet privateParts = hrow.getPrivateParts (); + this.book = privateParts.book; + this.sheet = privateParts.sheet; @@ -153,2 +198,3 @@ - short xfindex = sheet.getSheet().getXFIndexForColAt(col); - setCellType(type,false,row,col,xfindex); + short xfindex = sheet.getSheet().getXFIndexForColAt((short)col); + setCellType(type,false,privateParts.row,(short)col,xfindex); + hrow.initNewCell(this); @@ -189 +234,0 @@ -