彩票走势图

logo Aspose中文文档
文档彩票走势图>>Aspose中文文档>>将项目符号或编号添加到 NPOI 中的列表

将项目符号或编号添加到 NPOI 中的列表


Aspose.Words是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。

Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

Aspose.Words for .NET 最新下载

Aspose.Words

using NPOI.XWPF.UserModel;
XWPFDocument doc = new XWPFDocument();
//simple bullet
XWPFNumbering numbering = doc.CreateNumbering();
string abstractNumId = numbering.AddAbstractNum();
string numId = numbering.AddNum(abstractNumId);
XWPFParagraph p0 = doc.CreateParagraph();
XWPFRun r0 = p0.CreateRun();
r0.SetText("simple bullet");
r0.SetBold(true);
r0.FontFamily = "Courier";
r0.FontSize = 12;
XWPFParagraph p1 = doc.CreateParagraph();
XWPFRun r1 = p1.CreateRun();
r1.SetText("first, create paragraph and run, set text");
p1.SetNumID(numId);
XWPFParagraph p2 = doc.CreateParagraph();
XWPFRun r2 = p2.CreateRun();
r2.SetText("second, call XWPFDocument.CreateNumbering() to create numbering");
p2.SetNumID(numId);
XWPFParagraph p3 = doc.CreateParagraph();
XWPFRun r3 = p3.CreateRun();
r3.SetText("third, add AbstractNum[numbering.AddAbstractNum()] and Num(numbering.AddNum(abstractNumId))");
p3.SetNumID(numId);
XWPFParagraph p4 = doc.CreateParagraph();
XWPFRun r4 = p4.CreateRun();
r4.SetText("next, call XWPFParagraph.SetNumID(numId) to set paragraph property, CT_P.pPr.numPr");
p4.SetNumID(numId);
//multi level
abstractNumId = numbering.AddAbstractNum();
numId = numbering.AddNum(abstractNumId);
doc.CreateParagraph();
doc.CreateParagraph();
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("multi level bullet");
r1.SetBold(true);
r1.FontFamily = "Courier";
r1.FontSize =12 ;
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("first");
p1.SetNumID(numId, "0");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("first-first");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("first-second");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("first-third");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second");
p1.SetNumID(numId, "0");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second-first");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second-second");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second-third");
p1.SetNumID(numId, "1");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second-third-first");
p1.SetNumID(numId, "2");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("second-third-second");
p1.SetNumID(numId, "2");
p1 = doc.CreateParagraph();
r1 = p1.CreateRun();
r1.SetText("third");
p1.SetNumID(numId, "0");
FileStream sw = new FileStream("bullet-sample.docx", FileMode.Create);
doc.Write(sw);
sw.Close();

点击复制

NPOI

using Aspose.Words;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Font.Bold = true;
builder.Font.Name = "Courier";
builder.Font.Size = 12;
builder.Writeln("simple bullet");
builder.Font.ClearFormatting();
builder.ListFormat.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletSquare);
builder.Writeln("first, create paragraph and run, set text");
builder.Writeln("second, call XWPFDocument.CreateNumbering() to create numbering");
builder.Writeln("third, add AbstractNum[numbering.AddAbstractNum()] and Num(numbering.AddNum(abstractNumId))");
builder.Writeln("next, call XWPFParagraph.SetNumID(numId) to set paragraph property, CT_P.pPr.numPr");
builder.ListFormat.RemoveNumbers();
builder.InsertBreak(BreakType.ParagraphBreak);
//multi level
builder.Font.Bold = true;
builder.Font.Name = "Courier";
builder.Font.Size = 12;
builder.Writeln("multi level bullet");
builder.Font.ClearFormatting();
builder.ListFormat.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletSquare);
builder.Writeln("first");
builder.ListFormat.ListLevelNumber = 1;
builder.Writeln("first-first");
builder.Writeln("first-second");
builder.Writeln("first-third");
builder.ListFormat.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletSquare);
builder.ListFormat.ListLevelNumber = 0;
builder.Writeln("second");
builder.ListFormat.ListLevelNumber = 1;
builder.Writeln("second-first");
builder.Writeln("second-second");
builder.Writeln("second-third");
builder.ListFormat.ListLevelNumber = 2;
builder.Writeln("second-third-first");
builder.Writeln("second-third-second");
builder.ListFormat.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletSquare);
builder.ListFormat.ListLevelNumber = 0;
builder.Writeln("third");
builder.ListFormat.RemoveNumbers();
doc.Save("bullet-sample.docx");

点击复制

下载示例代码

  •  
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP