poi를 통해word 문서 표 내용 스타일과 눈썹 꼬리 스타일 설정

2729 단어
// word 
XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(sourceUrl));
// 
//---------------------------------------------------------
List tbls = document.getTables();
for (int i = 0; i < tbls.size(); i++) {
    String tbl = tbls.get(i).getText();
    tbls.get(i).setStyleID("tbl-text");   // styles.xml  styleId tbl-text
}
//---------------------------------------------------------

// 
//---------------------------------------------------------
List pageHeaders = document.getHeaderList();
for (int i = 0; i < pageHeaders.size(); i++) {
    List headerPara = pageHeaders.get(i).getParagraphs();
    for (int j = 0; j < headerPara.size(); j++) {
        headerPara.get(j).setStyle("page-header"); // styles.xml  styleId  page-header
    }
}

List pageFooters = document.getFooterList();
for (int i = 0; i < pageFooters.size(); i++) {
    List footerPara = pageFooters.get(i).getParagraphs();
    for (int j = 0; j < footerPara.size(); j++) {
        footerPara.get(j).setStyle("page-footer");// styles.xml  styleId  page-footer
    }
}

//---------------------------------------------------------

좋은 웹페이지 즐겨찾기