* @return Returns the refCell.
*/
public BiffRec[] getRefCells() {
double returnval = 0;
try {
Boundsheet bs= null; // this.parent_rec.getWorkBook().getWorkSheetByName(this.getSheetName());
getSheetName();
// handle misc sheets
if(sheetname != null) {
try{
bs = this.parent_rec.getWorkBook().getWorkSheetByName(sheetname);
}catch(Exception ex) { // guard against NPEs
bs = parent_rec.getSheet();
}
}else {
bs = parent_rec.getSheet();
sheetname= bs.getSheetName(); // 20080212 KSC
}
// TODO: check rc sanity here
int[] startloc = firstPtg.getIntLocation();
int startcol = startloc[1];
int startrow = startloc[0];
int[] endloc = lastPtg.getRealIntLocation();
int endcol = endloc[1];
int endrow = endloc[0];
// loop through the cols
int numcols= endcol-startcol;
if (numcols<0) numcols= startcol-endcol; // 20090521 KSC: may have range switched so that firstPtg>lastPtg (example in named ranges in tcr_formatted_2007.xlsm)
numcols++;
int numrows= endrow-startrow;
if (numrows<0) numrows= startrow-endrow; // 20090521 KSC: may have range switched so that firstPtg>lastPtg (example in named ranges in tcr_formatted_2007.xlsm)
numrows++;
int totcell= numcols*numrows;
if(totcell==0)totcell++;
if (totcell < 0) {
Logger.logErr("PtgArea.getRefCells. Error in Ptg locations: " + firstPtg.toString() + ":" + lastPtg.toString());
totcell= 0;
}
refCell = new BiffRec[totcell];
int rowctr = 0;
// 20090521 KSC: try to handle both cases i.e. ranges such that first<last or first>last
if (startcol<endcol)endcol++;
else endcol--;
if (startrow<endrow)endrow++;
else endrow--;
while (startcol!=endcol) {
int rowpos= startrow;
while (rowpos!=endrow) {
Row r = bs.getRowByNumber(rowpos);
if (r!=null)
refCell[rowctr] = (BiffRec)r.getCell((short)(startcol));
rowctr++;
if (rowpos<endrow)rowpos++;
else rowpos--;