java怎么设置序号_Java 添加Word项目符号、编号列表
import com.spire.doc.*;
import com.spire.doc.documents.ListPatternType;
import com.spire.doc.documents.Paragraph;
public class AddList {
public static void main(String[]args){
//加載測(cè)試文檔
Document doc = new Document();
doc.loadFromFile("test.docx");
//獲取第一節(jié)
Section sec = doc.getSections().get(0);
//給指定段落設(shè)置符號(hào)列表
for(int i = 1; i< 5;i++){
Paragraph para = sec.getParagraphs().get(i);
para.getListFormat().applyBulletStyle();
para.getListFormat().getCurrentListLevel().setNumberPosition(-5);
para.getListFormat().getCurrentListLevel().setTextPosition(10);
}
//給指定段落設(shè)置編號(hào)列表(編號(hào)列表樣式默認(rèn)是阿拉伯?dāng)?shù)字,如需其他樣式可自行設(shè)置數(shù)字樣式)
for (int j = 7; j < 10 ; j++){
Paragraph para = sec.getParagraphs().get(j);
para.getListFormat().applyNumberedStyle();
para.getListFormat().getCurrentListLevel().setNumberPosition(-5);
para.getListFormat().getCurrentListLevel().setTextPosition(10);
}
for (int z = 10; z < 13 ; z++) {
Paragraph para = sec.getParagraphs().get(z);
para.getListFormat().applyNumberedStyle();
para.getListFormat().getCurrentListLevel().setNumberPosition(-5);
para.getListFormat().setListLevelNumber(2);//設(shè)置列表級(jí)別(不設(shè)置列表級(jí)別時(shí),默認(rèn)級(jí)別為1級(jí)列表)
para.getListFormat().getCurrentListLevel().setPatternType(ListPatternType.Low_Roman);//設(shè)置編號(hào)列表數(shù)字樣式為小寫羅馬數(shù)字
para.getListFormat().getCurrentListLevel().setTextPosition(40);
}
//保存文檔
doc.saveToFile("Addlist.docx",FileFormat.Docx_2013);
doc.dispose();
}
}
總結(jié)
以上是生活随笔為你收集整理的java怎么设置序号_Java 添加Word项目符号、编号列表的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何在2022年建立自己的NFT市场平台
- 下一篇: Java在手机平台上的Porting