- Home
- Forum
- ASP.NET MVC
- table[y, x].Paragraphs[0].Text
table[y, x].Paragraphs[0].Text
3 Replies
SY
Sethumanikkam Yogendran
Syncfusion Team
October 26, 2016 06:36 AM UTC
Hi Customer,
Thank you for contacting Syncfusion support.
On further analyzing with given code snippet, we suspect you’re trying to set Bold formatting for complete text in particular paragraph. It is not possible to set Bold formatting directly for all text in paragraph. We achieved your requirement by iterate each text range and set Bold formatting to particular paragraph.
Please refer the following code snippets which illustrates the same.
for (int i = 0; i < (table[y, x].Paragraphs[0] as WParagraph).ChildEntities.Count; i++)
{
Entity entity = paragraph.ChildEntities[i];
//A paragraph can have child elements such as text, image, hyperlink, symbols, etc.,
if( entity.EntityType == EntityType.TextRange)
//Set Bold to text.
(entity as WTextRange).CharacterFormat.Bold = true;
}
Please refer the following links to know more about how to work with table and text.
https://help.syncfusion.com/file-formats/docio/working-with-tables
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text
Please refer IterateParagraph from the following link to know more about how to iterate through document elements.
https://help.syncfusion.com/file-formats/docio/working-with-word-document#iterating-through-document-elements
If we misunderstood your requirement, kindly update us requirement with clear description. Thereby we will analyze further on the mentioned requirement and update you with appropriate solution.
Please let us know if you have any other questions.
Thanks,
Sethumanikkam.Y
Thank you for contacting Syncfusion support.
On further analyzing with given code snippet, we suspect you’re trying to set Bold formatting for complete text in particular paragraph. It is not possible to set Bold formatting directly for all text in paragraph. We achieved your requirement by iterate each text range and set Bold formatting to particular paragraph.
Please refer the following code snippets which illustrates the same.
for (int i = 0; i < (table[y, x].Paragraphs[0] as WParagraph).ChildEntities.Count; i++)
{
Entity entity = paragraph.ChildEntities[i];
//A paragraph can have child elements such as text, image, hyperlink, symbols, etc.,
if( entity.EntityType == EntityType.TextRange)
//Set Bold to text.
(entity as WTextRange).CharacterFormat.Bold = true;
}
Please refer the following links to know more about how to work with table and text.
https://help.syncfusion.com/file-formats/docio/working-with-tables
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text
Please refer IterateParagraph from the following link to know more about how to iterate through document elements.
https://help.syncfusion.com/file-formats/docio/working-with-word-document#iterating-through-document-elements
If we misunderstood your requirement, kindly update us requirement with clear description. Thereby we will analyze further on the mentioned requirement and update you with appropriate solution.
Please let us know if you have any other questions.
Thanks,
Sethumanikkam.Y
TE
Testname
October 26, 2016 09:17 AM UTC
AT "paragraph.ChildEntities[i]" I get a 'System.ArgumentOutOfRangeException'. What to do ?
SY
Sethumanikkam Yogendran
Syncfusion Team
October 26, 2016 09:45 AM UTC
Hi Customer,
Sorry for the inconvenience caused.
You should iterate the particular paragraph in which you want to set Bold formatting to the Text.
Please refer the following code snippets in which we have get the paragraph and iterated each text from entity collection and applied Bold formatting to that.
WParagraph paragraph = table[y, x].Paragraphs[0] as WParagraph;
for (int i = 0; i < paragraph.ChildEntities.Count; i++)
{
Entity entity = paragraph.ChildEntities[i];
//A paragraph can have child elements such as text, image, hyperlink, symbols, etc.,
if (entity.EntityType == EntityType.TextRange)
//Set Bold to text.
(entity as WTextRange).CharacterFormat.Bold = true;
}
Note: We have used given code snippet to get paragraph which is highlighted above.
Please let us know if you have any other questions.
Thanks,
Sethumanikkam.Y
Sorry for the inconvenience caused.
You should iterate the particular paragraph in which you want to set Bold formatting to the Text.
Please refer the following code snippets in which we have get the paragraph and iterated each text from entity collection and applied Bold formatting to that.
WParagraph paragraph = table[y, x].Paragraphs[0] as WParagraph;
for (int i = 0; i < paragraph.ChildEntities.Count; i++)
{
Entity entity = paragraph.ChildEntities[i];
//A paragraph can have child elements such as text, image, hyperlink, symbols, etc.,
if (entity.EntityType == EntityType.TextRange)
//Set Bold to text.
(entity as WTextRange).CharacterFormat.Bold = true;
}
Note: We have used given code snippet to get paragraph which is highlighted above.
Please let us know if you have any other questions.
Thanks,
Sethumanikkam.Y
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TE Testname
- Oct 25, 2016 02:06 PM UTC
- Oct 26, 2016 09:45 AM UTC