Skip to content

Commit

Permalink
Refactor: Add Cell.getCellType
Browse files Browse the repository at this point in the history
  • Loading branch information
dplusic committed Feb 5, 2023
1 parent 5be950b commit 4125b8e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion fastexcel-writer/src/main/java/org/dhatim/fastexcel/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void write(Writer w, int r, int c) throws IOException {
w.append(" s=\"").append(style).append('\"');
}
if (value != null && !(value instanceof Formula)) {
w.append(" t=\"").append((value instanceof CachedString) ? "s" : (value instanceof Boolean ? "b" : (value instanceof String ? "inlineStr" : "n"))).append('\"');
w.append(" t=\"").append(getCellType(value)).append('\"');
}
w.append(">");
if (value instanceof Formula) {
Expand Down Expand Up @@ -80,6 +80,18 @@ void write(Writer w, int r, int c) throws IOException {
}
}

static String getCellType(Object value) {
if (value instanceof CachedString) {
return "s";
} else if (value instanceof Boolean) {
return "b";
} else if (value instanceof String) {
return "inlineStr";
} else {
return "n";
}
}

void setValue(Workbook wb, String v, boolean inline) {
value = inline ? v : (v == null ? null : wb.cacheString(v));
}
Expand Down

0 comments on commit 4125b8e

Please sign in to comment.