Reading style names in table cell of doc file in Apache-POI -
i able read table cells, wanted also read applied style name of each cell of row in table. how can accomplish this?
edit
following code snip have tried. able read cell text applied pstyle(para style), not able read rstyles.
private static void processdoc(string path) throws exception { poifsfilesystem fis = new poifsfilesystem(new fileinputstream(path)); hwpfdocument wddoc = new hwpfdocument(fis); // list style names , indexes in stylesheet /*for (int j = 0; j < wddoc.getstylesheet().numstyles(); j++) { if (wddoc.getstylesheet().getstyledescription(j) != null) { system.out.println(j + ": " + wddoc.getstylesheet().getstyledescription(j).getname()); } else { // getstyledescription returned null system.out.println(j + ": " + null); } }*/ // set range entire document range range = wddoc.getrange(); (int = 0; < range.numparagraphs(); i++) { paragraph p = range.getparagraph(i); // check if style index greater total number of styles if (wddoc.getstylesheet().numstyles() > p.getstyleindex()) { //system.out.println(wddoc.getstylesheet().numstyles() + " -> " + p.getstyleindex()); styledescription style = wddoc.getstylesheet().getstyledescription(p.getstyleindex()); string stylename = style.getname(); // write style name , associated text system.out.println(stylename + " -> " + p.text().replaceall("[\u0000-\u001f]", "")); } else { system.out.println("\n" + wddoc.getstylesheet().numstyles() + " ----> " + p.getstyleindex()); } } }
apache-poi
No comments:
Post a Comment