Why does jExcelAPI dump warnings in stderr and how to stop this behaviour?

一个人想着一个人 提交于 2019-12-14 02:33:55

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/7860834/why-does-jexcelapi-dump-warnings-in-stderr-and-how-to-stop-this-behaviour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!