问题描述
我使用的Apache POI API
生成Excel表在我的Java应用程序。这是在Excel中设置数据与类型为字符串动态到来。 对于列1,值是字母数字。当我生成Excel中,它会给我的绿色标志与警示的号码存储为文本或细胞的文本日期2位数年的
我想删除的警告。
我发现,从Excel中我们可以标记一个单元格为忽略错误,忽略警告。
怎么做编程或有任何其他的替代方案来实现这一任务呢?
我还附上了截图显示了绿色标志警告。
code:
如果(cellValue = NULL&放大器;!及(shouldBeRightAlign))
{
CELLTYPE = Cell.CELL_TYPE_NUMERIC;
}
否则,如果(cellValue!= NULL)
{
CELLTYPE = Cell.CELL_TYPE_STRING;
}
cell.setCellValue(cellValue);
将细胞类型
这样的:
HSSFRow行= sheet.createRow(sheet.getLastRowNum());
HSSFCell细胞= row.createCell(0);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
有关字母和字符
细胞类型将是 Cell.CELL_TYPE_STRING
的数量,细胞类型将 CELL_TYPE_NUMERIC
您可以得到更多的细胞类型从和文档。
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.
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.
Code :
if (cellValue != null && (shouldBeRightAlign))
{
cellType = Cell.CELL_TYPE_NUMERIC;
}
else if (cellValue != null)
{
cellType = Cell.CELL_TYPE_STRING;
}
cell.setCellValue(cellValue);
Set the cell type
like :
HSSFRow row = sheet.createRow(sheet.getLastRowNum());
HSSFCell cell = row.createCell(0);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
For alphanumeric and Character
cell type will be Cell.CELL_TYPE_STRING
for number, cell type will be CELL_TYPE_NUMERIC
You can get more on cell type from Cell and HSSFCell documentation.
这篇关于如何在Java中使用的Apache POI删除Excel中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!