Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sat Mar 19, 2016 1:43 pm

Is there a way in my code to find out what number Spire will insert into the Word document for a numbered list? I would like to save the generated numbers to a SQL database so I can renumber lists. So if 1.2.3 updated to 1.2.4, I could update the database with the new number.

I tried the sample code from the website and it works great. But I'm not seeing where I can determine the list number before it is inserted. This is part of the example code . . .

ListStyle listStyle = new ListStyle(document, ListType.Numbered);
listStyle.Name = "levelstyle";
listStyle.Levels[0].PatternType = ListPatternType.Arabic;
listStyle.Levels[1].NumberPrefix = "\x0000.";
listStyle.Levels[1].PatternType = ListPatternType.Arabic;
listStyle.Levels[2].NumberPrefix = "\x0000.\x0001.";
listStyle.Levels[2].PatternType = ListPatternType.Arabic;
document.ListStyles.Add(listStyle);


Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("The first item");
paragraph.ApplyStyle(BuiltinStyle.Heading1);
paragraph.ListFormat.ApplyStyle("levelstyle");

Is this possible?

dave.holly@verizon.net
 
Posts: 3
Joined: Sat Mar 19, 2016 2:02 am

Mon Mar 21, 2016 3:42 am

Hi,

Thanks for your posting.
You can use string str = paragraph.ListText; to get existed paragraph's list number.
The code paragraph.ListFormat.CurrentListLevel.StartAt can renumber list.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Mon Mar 21, 2016 4:07 pm

Hi,

I get an error saying Spire.Doc.Documents.Paragraph doesn't contain a definition for ListText. Is that only available in the full version? I'm using the free download for now.

dave.holly@verizon.net
 
Posts: 3
Joined: Sat Mar 19, 2016 2:02 am

Tue Mar 22, 2016 1:35 am

Hi,

Yes, it is only available in the full version now.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc