Developer technologies | .NET | Other
Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
How to correct the line below, to have Bold effect?
RunProperties runProperties = run.AppendChild(new RunProperties(new Bold { Val = BoldValues.Single }));
Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Answer accepted by question author
Based on MSDN sample, this creates a .docx with a bold text =>
string sFilePath = "Test.docx";
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(sFilePath, WordprocessingDocumentType.Document))
{
// Add a main document part.
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
// Create the document structure and add some text.
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
Run run = para.AppendChild(new Run());
run.Append(new Text("This is a bold text"));
RunProperties runProperties = new RunProperties();
runProperties.Append(new Bold());
run.RunProperties = runProperties;
}