1 package org.simantics.excel.poi.parser.streaming;
\r
3 import java.util.Calendar;
\r
4 import java.util.Date;
\r
6 import org.apache.poi.ss.formula.FormulaParseException;
\r
7 import org.apache.poi.ss.usermodel.Cell;
\r
8 import org.apache.poi.ss.usermodel.CellStyle;
\r
9 import org.apache.poi.ss.usermodel.CellType;
\r
10 import org.apache.poi.ss.usermodel.Comment;
\r
11 import org.apache.poi.ss.usermodel.ExcelStyleDateFormatter;
\r
12 import org.apache.poi.ss.usermodel.Hyperlink;
\r
13 import org.apache.poi.ss.usermodel.RichTextString;
\r
14 import org.apache.poi.ss.usermodel.Row;
\r
15 import org.apache.poi.ss.usermodel.Sheet;
\r
16 import org.apache.poi.ss.util.CellAddress;
\r
17 import org.apache.poi.ss.util.CellRangeAddress;
\r
19 public class CellImpl implements Cell{
\r
21 private RowImpl row;
\r
24 public CellImpl(RowImpl row, int index) {
\r
30 private String getType() {
\r
31 return row.cellTypes.get(index);
\r
35 public boolean getBooleanCellValue() {
\r
36 return 1 == Integer.parseInt(getStringCellValue());
\r
40 public Date getDateCellValue() {
\r
41 ExcelStyleDateFormatter formatter = new ExcelStyleDateFormatter(""); //FIXME: date format
\r
43 return formatter.parse(getStringCellValue());
\r
44 } catch (Exception e) {
\r
50 public byte getErrorCellValue() {
\r
51 // TODO Auto-generated method stub
\r
56 public double getNumericCellValue() {
\r
57 return Double.parseDouble(getStringCellValue());
\r
61 public RichTextString getRichStringCellValue() {
\r
66 public String getStringCellValue() {
\r
67 return row.cellData.get(index);
\r
72 public int getCellType() {
\r
73 String type = getType();
\r
74 if ("v".equals(type)) {
\r
75 return CELL_TYPE_NUMERIC;
\r
76 } else if ("n".equals(type)) {
\r
77 return CELL_TYPE_NUMERIC;
\r
78 } else if ("s".equals(type)) {
\r
79 return CELL_TYPE_STRING;
\r
80 } else if ("b".equals(type)) {
\r
81 return CELL_TYPE_STRING;
\r
82 } else if ("inlineStr".equals(type)) {
\r
83 return CELL_TYPE_STRING;
\r
85 return CELL_TYPE_STRING;
\r
92 public Row getRow() {
\r
97 public int getRowIndex() {
\r
98 return row.getRowNum();
\r
103 public CellRangeAddress getArrayFormulaRange() {
\r
109 public int getCachedFormulaResultType() {
\r
114 public Comment getCellComment() {
\r
119 public String getCellFormula() {
\r
124 public CellStyle getCellStyle() {
\r
129 public int getColumnIndex() {
\r
134 public Hyperlink getHyperlink() {
\r
140 public Sheet getSheet() {
\r
141 return row.getSheet();
\r
145 public boolean isPartOfArrayFormulaGroup() {
\r
150 public void removeCellComment() {
\r
155 public void setAsActiveCell() {
\r
160 public void setCellComment(Comment comment) {
\r
165 public void setCellErrorValue(byte value) {
\r
170 public void setCellFormula(String formula) throws FormulaParseException {
\r
175 public void setCellStyle(CellStyle style) {
\r
180 public void setCellType(int cellType) {
\r
185 public void setCellValue(boolean value) {
\r
190 public void setCellValue(Calendar value) {
\r
195 public void setCellValue(Date value) {
\r
200 public void setCellValue(double value) {
\r
205 public void setCellValue(RichTextString value) {
\r
210 public void setCellValue(String value) {
\r
215 public void setHyperlink(Hyperlink link) {
\r
221 public CellAddress getAddress() {
\r
222 return new CellAddress(this);
\r
227 public CellType getCachedFormulaResultTypeEnum() {
\r
228 throw new UnsupportedOperationException();
\r
233 public CellType getCellTypeEnum() {
\r
234 String type = getType();
\r
235 if ("v".equals(type)) {
\r
236 return CellType.NUMERIC;
\r
237 } else if ("n".equals(type)) {
\r
238 return CellType.NUMERIC;
\r
239 } else if ("s".equals(type)) {
\r
240 return CellType.STRING;
\r
241 } else if ("b".equals(type)) {
\r
242 return CellType.STRING;
\r
243 } else if ("inlineStr".equals(type)) {
\r
244 return CellType.STRING;
\r
246 return CellType.STRING;
\r
250 public void setCellType(CellType arg0) {
\r
251 throw new UnsupportedOperationException();
\r
257 public void removeHyperlink() {
\r
258 throw new UnsupportedOperationException();
\r