如何使用apache poi在JAVA中删除Excel中的警告? [英] How to remove warning in Excel using apache poi in JAVA?

查看:202
本文介绍了如何使用apache poi在JAVA中删除Excel中的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 apache poi api 在我的应用程序中生成Excel表单。在excel中设置的数据将以类型字符串动态进行。 对于column1,值为字母数字。当我生成Excel时,它会给我绿色的指示,警告数字存储为文本文本日期与2位数年份在单元格。

I am using apache poi api to generate Excel sheet in my application in java. Data that are set in excel are coming dynamically with type string. For column1, values are alphanumeric. When I generate Excel, it will give me green indication with warning "Number Stored as Text" or "Text date with 2-digit year" on cell.

我想删除那个警告。
我发现从excel我们可以将单元格标记为忽略错误,忽略该警告。

I want to remove that warning. I found that from excel we can flag a cell as 'ignore error', to ignore the warning.

如何以编程方式或有其他任何方式另外一个可以实现这个任务的人呢?

How to do it programmatically or is there any other alternative to achieve this task ?

我还附上了绿色标记显示警告的截图。

I also have attached screenshot that shows warning with green mark.

代码:

if (cellValue != null && (shouldBeRightAlign))
{
 cellType = Cell.CELL_TYPE_NUMERIC;
}
else if (cellValue != null)
{
 cellType = Cell.CELL_TYPE_STRING;
}
cell.setCellValue(cellValue);


推荐答案

API现在提供了一个相应的方法

public void addIgnoredErrors(CellRangeAddress region,
                    IgnoredErrorType... ignoredErrorTypes)

这篇关于如何使用apache poi在JAVA中删除Excel中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆