My requirement is to create a list in three columns. data will come from DB.
See sample output (requirement) as attachment.
Please suggest implementation approach and sample code (.NET).List-3cols.PNG (267.5 KB)
TextColumn class represents a single text column. You can insert your desired content into text columns. Following code example shows how to create multiple columns of different widths in a section using DocumentBuilder.
DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.PageSetup.TextColumns; // Show vertical line between columns columns.LineBetween = true; // Indicate we want to create column with different widths columns.EvenlySpaced = false; // Create two columns, note they will be created with zero widths, need to set them columns.SetCount(2); // Set the first column to be narrow TextColumn c1 = columns; c1.Width = 100; c1.SpaceAfter = 20; // Set the second column to take the rest of the space available on the page TextColumn c2 = columns; PageSetup ps = builder.PageSetup; double contentWidth = ps.PageWidth - ps.LeftMargin - ps.RightMargin; c2.Width = contentWidth - c1.Width - c1.SpaceAfter; builder.Writeln("Narrow column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Wide column 2."); builder.Document.Save(ArtifactsDir + "PageSetup.ColumnsCustomWidth.doc");
Moreover, you can insert a table into document with three columns, remove its border and insert the content into them. Please read the following article about working with tables.
Working with Tables
Thanks for your reply.
Now I understand I can I create columns.
Is it possible to create columns in specific location in work file (e.g. 2nd page or after some header in 3rd page etc.)? Could you please also provide few more code about how to create list?
Yes, you can achieve your requirement using Aspose.Words. We suggest you please move the cursor to the desired location and insert the column break. After inserting the column break, insert the content according to your requirement. Please read the following articles.
Moving the Cursor
Use DocumentBuilder to Insert Document Elements