为什么 jExcelAPI 在 stderr 中转储警告以及如何停止这种行为?
在尝试使用 jExcelAPI 读取 xls 文件时,我发现该库在 stderr 中转储了大量信息,有时这些信息不相关。例如,此代码片段会导致大量“警告”转储到 stderr 流上:
Workbook workbook = Workbook.getWorkbook(new File(flname));
//For each sheet in the workbook
for (int currentSheet = 0; currentSheet < workbook.getNumberOfSheets(); currentSheet++)
{
Sheet sheet = workbook.getSheet(currentSheet);
System.out.println("Currently processing " + sheet.getName());
}
警告如下:
Currently processing frst sheet
Warning: Cell C33680 already contains data
Warning: Cell D33680 already contains data
Warning: Cell E33680 already contains data
Warning: Cell F33680 already contains data
Warning: Cell B33680 already contains data
Currently processing Lst Sheet
如何避免库转储所有这些不需要的数据?另外,我不明白为什么代码甚至会查看工作表的所有单元格,而我要求它做的只是列出工作表的名称(我知道 Workbook.getSheetNames() 可以执行类似的任务 - 但是假设我想打印工作表的名称和工作表中单个单元格的内容)。
我是否错误地使用了该库?
While trying to read an xls file using jExcelAPI, I find that the library dumps a lot of information in stderr, sometimes this information is not relevant. For example, this code snippet causes lots of 'Warnings' to be dumped on stderr stream:
Workbook workbook = Workbook.getWorkbook(new File(flname));
//For each sheet in the workbook
for (int currentSheet = 0; currentSheet < workbook.getNumberOfSheets(); currentSheet++)
{
Sheet sheet = workbook.getSheet(currentSheet);
System.out.println("Currently processing " + sheet.getName());
}
The warnings are like:
Currently processing frst sheet
Warning: Cell C33680 already contains data
Warning: Cell D33680 already contains data
Warning: Cell E33680 already contains data
Warning: Cell F33680 already contains data
Warning: Cell B33680 already contains data
Currently processing Lst Sheet
How to avoid the library from dumping all this unwanted data? Also I do not understand why the code even looks at all the cells of the sheet, when all I am asking for it to do is list the name of the sheets (I understand that Workbook.getSheetNames() can do a similar task - but say I wanted to print the name of the sheet and contents of a single cell in the sheet).
Am I using the library incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从未使用过这个库,但是快速查看 Logger.initializeLogger() 看起来默认情况下它会尝试使用 Logger Log4J。你的 CLASSPATH 中有 Log4J 吗?您还可以使用 SLF4J 桥。
当您成功地将 JExcelAPI 重定向到日志记录框架时,您可以配置转储哪些消息(以及转储位置)。
I have never used this library, however quick look at Logger.initializeLogger() it looks like by default it tries to Log using Log4J. Do you have Log4J on your CLASSPATH? You can also use SLF4J bridge.
When you successfully redirect JExcelAPI into logging framework, you can configure which messages are dumped (and where).