为什么jExcelAPI在stderr中转储警告,以及如何停止这种行为? [英] Why does jExcelAPI dump warnings in stderr and how to stop this behaviour?

查看:179
本文介绍了为什么jExcelAPI在stderr中转储警告,以及如何停止这种行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用jExcelAPI读取xls文件时,我发现该库在stderr中转储了很多信息,有时这些信息是不相关的.例如,此代码段导致许多警告"被转储到stderr流上:

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());
    }

警告类似:

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()可以完成类似的任务-但说我想打印工作表的名称和工作表中单个单元格的内容.

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?

推荐答案

我从未使用过此库,但是请快速浏览 SLF4J桥.

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.

当您成功将JExcelAPI重定向到日志记录框架时,您可以配置要转储的消息(以及转储位置).

When you successfully redirect JExcelAPI into logging framework, you can configure which messages are dumped (and where).

这篇关于为什么jExcelAPI在stderr中转储警告,以及如何停止这种行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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