- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
单元格的内容决定了单元格的类型,POI中定义的7种单元格类型:
Excel中存在错误单元格,在POI中是怎么表现的呢
org.apache.poi.ss.usermodel.FormulaError1
package org.apache.poi.ss.usermodel;
import java.util.Map;
import org.apache.poi.util.Internal;
import java.util.HashMap;
/**
* Enumerates error values in SpreadsheetML formula calculations.
*
* See also OOO's excelfileformat.pdf (2.5.6)
*/
public enum FormulaError {
@Internal
_NO_ERROR(-1, "(no error)"),
/**
* Intended to indicate when two areas are required to intersect, but do not.
* <p>Example:
* In the case of SUM(B1 C1), the space between B1 and C1 is treated as the binary
* intersection operator, when a comma was intended. end example]
* </p>
*/
NULL(0x00, "#NULL!"),
/**
* Intended to indicate when any number, including zero, is divided by zero.
* Note: However, any error code divided by zero results in that error code.
*/
DIV0(0x07, "#DIV/0!"),
/**
* Intended to indicate when an incompatible type argument is passed to a function, or
* an incompatible type operand is used with an operator.
* <p>Example:
* In the case of a function argument, text was expected, but a number was provided
* </p>
*/
VALUE(0x0F, "#VALUE!"),
/**
* Intended to indicate when a cell reference is invalid.
* <p>Example:
* If a formula contains a reference to a cell, and then the row or column containing that cell is deleted,
* a #REF! error results. If a worksheet does not support 20,001 columns,
* OFFSET(A1,0,20000) will result in a #REF! error.
* </p>
*/
REF(0x17, "#REF!"),
/**
* Intended to indicate when what looks like a name is used, but no such name has been defined.
* <p>Example:
* XYZ/3, where XYZ is not a defined name. Total is & A10,
* where neither Total nor is is a defined name. Presumably, "Total is " & A10
* was intended. SUM(A1C10), where the range A1:C10 was intended.
* </p>
*/
NAME(0x1D, "#NAME?"),
/**
* Intended to indicate when an argument to a function has a compatible type, but has a
* value that is outside the domain over which that function is defined. (This is known as
* a domain error.)
* <p>Example:
* Certain calls to ASIN, ATANH, FACT, and SQRT might result in domain errors.
* </p>
* Intended to indicate that the result of a function cannot be represented in a value of
* the specified type, typically due to extreme magnitude. (This is known as a range
* error.)
* <p>Example: FACT(1000) might result in a range error. </p>
*/
NUM(0x24, "#NUM!"),
/**
* Intended to indicate when a designated value is not available.
* <p>Example:
* Some functions, such as SUMX2MY2, perform a series of operations on corresponding
* elements in two arrays. If those arrays do not have the same number of elements, then
* for some elements in the longer array, there are no corresponding elements in the
* shorter one; that is, one or more values in the shorter array are not available.
* </p>
* This error value can be produced by calling the function NA
*/
NA(0x2A, "#N/A"),
// These are POI-specific error codes
// It is desirable to make these (arbitrary) strings look clearly different from any other
// value expression that might appear in a formula. In addition these error strings should
// look unlike the standard Excel errors. Hence tilde ('~') was used.
/**
* POI specific code to indicate that there is a circular reference
* in the formula
*/
CIRCULAR_REF(0xFFFFFFC4, "~CIRCULAR~REF~"),
/**
* POI specific code to indicate that the funcition required is
* not implemented in POI
*/
FUNCTION_NOT_IMPLEMENTED(0xFFFFFFE2, "~FUNCTION~NOT~IMPLEMENTED~");
private final byte type;
private final int longType;
private final String repr;
private FormulaError(int type, String repr) {
this.type = (byte)type;
this.longType = type;
this.repr = repr;
}
/**
* @return numeric code of the error
*/
public byte getCode() {
return type;
}
/**
* @return long (internal) numeric code of the error
*/
public int getLongCode() {
return longType;
}
/**
* @return string representation of the error
*/
public String getString() {
return repr;
}
private static final Map<String, FormulaError> smap = new HashMap<String, FormulaError>();
private static final Map<Byte, FormulaError> bmap = new HashMap<Byte, FormulaError>();
private static final Map<Integer, FormulaError> imap = new HashMap<Integer, FormulaError>();
static{
for (FormulaError error : values()) {
bmap.put(error.getCode(), error);
imap.put(error.getLongCode(), error);
smap.put(error.getString(), error);
}
}
public static final boolean isValidCode(int errorCode) {
for (FormulaError error : values()) {
if (error.getCode() == errorCode) return true;
if (error.getLongCode() == errorCode) return true;
}
return false;
}
public static FormulaError forInt(byte type) throws IllegalArgumentException {
FormulaError err = bmap.get(type);
if(err == null) throw new IllegalArgumentException("Unknown error type: " + type);
return err;
}
public static FormulaError forInt(int type) throws IllegalArgumentException {
FormulaError err = imap.get(type);
if(err == null) err = bmap.get((byte)type);
if(err == null) throw new IllegalArgumentException("Unknown error type: " + type);
return err;
}
public static FormulaError forString(String code) throws IllegalArgumentException {
FormulaError err = smap.get(code);
if(err == null) throw new IllegalArgumentException("Unknown error code: " + code);
return err;
}
}
package hssf.sheet.cell;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
public class ExportDataCell {
public static void main(String[] args) throws Exception {
File file = new File("C:\\Users\\Administrator\\Desktop\\test.xls");
if (file.exists()) {
file.delete();
}
BufferedOutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream("C:\\Users\\Administrator\\Desktop\\test.xls"));
exportExcel(out);
} finally {
out.close();
}
}
private static void exportExcel(BufferedOutputStream out) throws IOException {
Workbook wb = new HSSFWorkbook();
//Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("各种类型单元格");
sheet.createRow(0).createCell(0).setCellValue(1.1);
sheet.createRow(1).createCell(0).setCellValue(new Date());
sheet.createRow(2).createCell(0).setCellValue(Calendar.getInstance());
sheet.createRow(3).createCell(0).setCellValue("字符串");
sheet.createRow(4).createCell(0).setCellValue(true);
sheet.createRow(5).createCell(0).setCellType(CellType.ERROR);
wb.write(out);
}
}
我已经尝试在我的 CSS 中添加一个元素来删除每三个 div 的 margin-right。不过,似乎只是出于某种原因影响了第 3 次和第 7 次。需要它在第 3、6、9 等日工作... CSS .s
如何使 div/input 闪烁或“脉冲”?例如,假设表单字段输入了无效值? 最佳答案 使用 CSS3 类似 on this page ,您可以将脉冲效果添加到名为 error 的类中: @-webk
我目前正在尝试构建一个简单的 wireframe来自 lattice 的情节包,但由沿 y 轴的数百个点组成。这导致绘图被线框网格淹没,您看到的只是一个黑色块。我知道我可以用 col=FALSE 完全
在知道 parent>div CSS 选择器在 IE 中无法识别后,我重新编码我的 CSS 样式,例如: div#bodyMain div#paneLeft>div{/*styles here*/}
我有两个 div,一个在另一个里面。当我将鼠标悬停 到最外面的那个时,我想改变它的颜色,没问题。但是,当我将鼠标悬停 到内部时,我只想更改它的颜色。这可能吗?换句话说,当 将鼠标悬停到内部 div 上
我需要展示这样的东西 有人可以帮忙吗?我可以实现以下输出 我正在使用以下代码:: GridView.builder( scrollDirection: Axis.vertical,
当 Bottom Sheet 像 Android 键盘一样打开时,是否有任何方法可以手动上推布局( ScrollView 或回收器 View 或整个 Activity )?或者你可以说我想以 Bott
我有以下代码,用于使用纯 HTML 和 CSS 显示翻转。当您将鼠标悬停在文本上时,它会更改左右图像。 在我测试的所有浏览器中都运行良好,Safari 4 除外。据我收集的信息,Safari 4 支持
我构建了某种 CMS,但在使用 TinyMCE 和 Bootstrap 时遇到了一些问题。 我有一个页面,其中概述了一个 div,如果用户单击该 div,他们可以从模态中选择图像。该图像被插入到一个
出于某种原因,当我设置一个过渡时,当我的鼠标悬停在一个元素上时,背景会改变颜色,它只适用于一个元素,但它们都共享同一个类?任何帮助我的 CSS .outer_ad { position:rel
好吧,这真的很愚蠢。我不知道 Android Studio 中的调试监视框架发生了什么。我有 1.5.1 的工作室。 是否有一些来自 intellij 的 secret 知识来展示它。 最佳答案 与以
我有这个标记: some code > 我正在尝试获取此布局: 注意:上一个和下一个按钮靠近#player 我正在尝试这样: .nextBtn{
网站:http://avuedesigns.com/index 首页有 6 个菜单项。我希望每件元素在您经过时都有自己的颜色。 这是当您将鼠标悬停在 div 上时将所有内容更改为白色的行 li#hom
我需要在 index.php 文件中显示它,但没有任何效果。我所有的文章都没有正确定位。我将其用作代码: 最佳答案 您可以首先检查您
我是一名优秀的程序员,十分优秀!