hi there,
I have data like this: mydata = “one two”
how to put in table’s cell to be separate lines:
one
two
or can we have bullets for each item?
regards
hi there,
I have data like this: mydata = “one two”
how to put in table’s cell to be separate lines:
one
two
or can we have bullets for each item?
regards
@ibox You can use code like the following to achieve this:
string data = "one\r\ntwo";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.StartTable();
builder.InsertCell();
builder.ListFormat.ApplyBulletDefault();
builder.Write(data);
builder.EndRow();
builder.EndTable();
doc.Save(@"C:\temp\out.docx");
out.docx (7.9 KB)
thanks u, Sir
Unfortunately all cell are bulleted.
Can we limited only to some columns? say, only column “Primary Asset” ?
regards
@ibox Could you please provide your current and expected output along with simple code that will allow us to reproduce the problem?
@ibox you can use ListFormat.RemoveNumbers()
to disable numbering:
string data = "one\r\ntwo";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.StartTable();
builder.InsertCell();
builder.ListFormat.ApplyBulletDefault();
builder.Write(data);
builder.InsertCell();
builder.ListFormat.RemoveNumbers();
builder.Write("This is a cell without bullets");
builder.EndRow();
builder.EndTable();
doc.Save(@"C:\temp\out.docx");
Please see our documentation to learn more how to work with lists:
https://docs.aspose.com/words/net/working-with-lists/
hi,
I have a data that are lists and also not list those will put in cells in a same table.
For the list, i want the builder has bullets, else no bullets.
regards and thanks
i attach the chunk codes
chunks.zip (1.9 KB)
ok, thank u Sir,
It works
I didn’t see before
regards
hi sir,
i found a weird, one of the data cannot bulleted properly:
cash & finances
i have tried to sanitize using Replace, but does not work:
string sclean = srcme.ssSTTextStrAspose.ssAttribute1.Replace("\r\n", string.Empty);
controls = controls + sclean + "\r\n";
regards
@ibox Most likely there is break between fina
and nces
in your data. But is it hard to say without your data. You are standing in a better position to debug the problem.
hi, thank, Sir
I have asked my mate, it is inputted as a field in a form, so there will be no chance to have a break. But suppose it is, how to sanitize it, in addition to replace\r\n? do wee need to replace \r and \n alone?
After debugging i think u are correct, but i don’t know what character is that…
And after replace ‘\r’ and ‘\n’ alone it works
regards
Hi Sir,
Instead of Circle bullets, can i have a square one?
regards and thanks
@ibox Sure, you can. Please see the following simple code:
string data = "one\r\ntwo";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create Bullet Square list.
List lst = doc.Lists.Add(ListTemplate.BulletSquare);
builder.StartTable();
builder.InsertCell();
// Apply the list.
builder.ListFormat.List = lst;
builder.Write(data);
builder.InsertCell();
builder.ListFormat.RemoveNumbers();
builder.Write("This is a cell without bullets");
builder.EndRow();
builder.EndTable();
doc.Save(@"C:\temp\out.docx");
Thank you, Sir.
It works for plain insert. But for insertHTM, it does not work:
List lst = doc.Lists.Add(ListTemplate.BulletSquare);
builder.ListFormat.List = lst;
builder.InsertHtml(ssAAssetCritical[i, j], true);
builder.ListFormat.RemoveNumbers();
regards
@ibox When you use InsertHtml
method formatting is taken from the source HTML. In your case, most likely HTML contains inline elements, like <span>
, in this case InsertHtml
does not insert a paragraph break so the following line builder.ListFormat.RemoveNumbers()
removes numbering from the current paragraph. For example the following code will not produce bulleted paragraph:
builder.ListFormat.List = lst;
builder.InsertHtml("<span>Some HTML span</span>", true);
builder.ListFormat.RemoveNumbers();
but the following will produce bulleted paragraph:
builder.ListFormat.List = lst;
builder.InsertHtml("<p>Some HTML paragraph</p>", true);
builder.ListFormat.RemoveNumbers();