开发者

Retrieving cell style information(specifically color) using POI event api

Am trying to create a web application which reads an existing xls file(we do not control file creation ) using POI and java.

The size of the uploaded file is quite large so the goal is to use event driven excel parsing APIs.

I was not able to find any API to access cell colors using the event driven approach.

However the uploaded excels have some logic based on the cell colors.

Any one has an idea how I can go about it开发者_开发技巧?

Thanks!


You probably want a FormatTrackingHSSFListener - that will grab the appropriate formatting and style records as they go past. When you the event API gives you a cell record, you'll be able to use the formatting listener to get at the style.

If you look at ExcelExtractor from Apache Tika, you'll see an example of using a FormatTrackingHSSFListener to get the cell style and format numbers based on the format applied in that cell style: https://svn.apache.org/repos/asf/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java

For colours you'll want to use something similar - the ExtendedFormatRecords hold the colour indexes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜