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){
//加載測試文檔
Document doc = new Document();
doc.loadFromFile("test.docx");
//獲取第一節
Section sec = doc.getSections().get(0);
//給指定段落設置符號列表
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);
}
//給指定段落設置編號列表(編號列表樣式默認是阿拉伯數字,如需其他樣式可自行設置數字樣式)
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);//設置列表級別(不設置列表級別時,默認級別為1級列表)
para.getListFormat().getCurrentListLevel().setPatternType(ListPatternType.Low_Roman);//設置編號列表數字樣式為小寫羅馬數字
para.getListFormat().getCurrentListLevel().setTextPosition(40);
}
//保存文檔
doc.saveToFile("Addlist.docx",FileFormat.Docx_2013);
doc.dispose();
}
}
總結
以上是生活随笔為你收集整理的java怎么设置序号_Java 添加Word项目符号、编号列表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何在2022年建立自己的NFT市场平台
- 下一篇: java美元兑换,(Java实现) 美元