1 19 20 package jxl.read.biff; 21 22 import java.text.NumberFormat ; 23 import java.text.DecimalFormat ; 24 25 import jxl.NumberCell; 26 import jxl.CellType; 27 import jxl.CellFeatures; 28 import jxl.format.CellFormat; 29 import jxl.biff.FormattingRecords; 30 31 35 class NumberValue implements NumberCell, CellFeaturesAccessor 36 { 37 40 private int row; 41 44 private int column; 45 48 private double value; 49 50 53 private NumberFormat format; 54 55 58 private CellFormat cellFormat; 59 60 63 private CellFeatures features; 64 65 68 private int xfIndex; 69 70 73 private FormattingRecords formattingRecords; 74 75 79 private boolean initialized; 80 81 84 private SheetImpl sheet; 85 86 89 private static DecimalFormat defaultFormat = new DecimalFormat ("#.###"); 90 91 101 public NumberValue(int r, int c, double val, 102 int xfi, 103 FormattingRecords fr, 104 SheetImpl si) 105 { 106 row = r; 107 column = c; 108 value = val; 109 format = defaultFormat; 110 xfIndex = xfi; 111 formattingRecords = fr; 112 sheet = si; 113 initialized = false; 114 } 115 116 123 final void setNumberFormat(NumberFormat f) 124 { 125 if (f != null) 126 { 127 format = f; 128 } 129 } 130 131 136 public final int getRow() 137 { 138 return row; 139 } 140 141 146 public final int getColumn() 147 { 148 return column; 149 } 150 151 156 public double getValue() 157 { 158 return value; 159 } 160 161 166 public String getContents() 167 { 168 return format.format(value); 169 } 170 171 176 public CellType getType() 177 { 178 return CellType.NUMBER; 179 } 180 181 186 public CellFormat getCellFormat() 187 { 188 if (!initialized) 189 { 190 cellFormat = formattingRecords.getXFRecord(xfIndex); 191 initialized = true; 192 } 193 194 return cellFormat; 195 } 196 197 202 public boolean isHidden() 203 { 204 ColumnInfoRecord cir = sheet.getColumnInfo(column); 205 206 if (cir != null && cir.getWidth() == 0) 207 { 208 return true; 209 } 210 211 RowRecord rr = sheet.getRowInfo(row); 212 213 if (rr != null && (rr.getRowHeight() == 0 || rr.isCollapsed())) 214 { 215 return true; 216 } 217 218 return false; 219 } 220 221 227 public NumberFormat getNumberFormat() 228 { 229 return format; 230 } 231 232 237 public CellFeatures getCellFeatures() 238 { 239 return features; 240 } 241 242 247 public void setCellFeatures(CellFeatures cf) 248 { 249 features = cf; 250 } 251 252 } 253 254 255 256 | Popular Tags |