Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.apache.poi.xssf.usermodel;
- import java.io.File;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.Comment;
- import org.apache.poi.ss.usermodel.Row;
- import org.junit.Test;
- public class TikaTest {
- @Test
- public void testme() throws Exception {
- int comm_cnt = 0;
- int comm_char_cnt = 0;
- int auth_cnt = 0;
- int auth_char_cnt = 0;
- XSSFWorkbook wb = new XSSFWorkbook(new File("598948.xlsx"));
- for (XSSFSheet s : wb) {
- for (Row r : s) {
- for (Cell c : r) {
- Comment cm = c.getCellComment();
- if (cm != null) {
- comm_cnt++;
- comm_char_cnt += cm.getString().getString().length();
- String author = cm.getAuthor();
- if (author != null) {
- auth_cnt++;
- auth_char_cnt += author.length();
- }
- }
- }
- }
- }
- wb.close();
- System.out.println(comm_cnt+" "+comm_char_cnt+" "+auth_cnt+" "+auth_char_cnt);
- // prints 103 17281 103 192
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment