.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
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 }));
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;
}