private static void Main()
{
using ( var docxDocument = new DocxDocument(SimpleTemplate.EmptyWordFile))
{
var builder = new DocxDocumentBuilder(docxDocument);
builder
.Tag(SimpleTemplate.ContentTagName,
x => x.Center.Paragraph(z => z.Bold.Text( "Hello Word!" )));
File .WriteAllBytes( string .Format( @"D:\Word.docx" ), docxDocument.ToArray());
}
}
* This source code was highlighted with Source Code Highlighter .
private static void Main()
{
string customerName = " .." ;
string orderNumber = "4" ;
string itemName1 = "" ;
string itemSumm1 = "5 000" ;
string itemName2 = " " ;
string itemSumm2 = "6 342" ;
string summ = "11 342" ;
using ( var docxDocument = new DocxDocument(SimpleTemplate.EmptyWordFile))
{
var builder = new DocxDocumentBuilder(docxDocument);
builder
.Tag(SimpleTemplate.ContentTagName,
x => x
.Center.Paragraph(z => z.Bold.Text( string .Format( " №{0}" , orderNumber)))
.Right.Paragraph( string .Format( " {0} ." , DateTime .Now.ToString( "dd MMMM yyyy" )))
.Left.Paragraph( string .Format( ", {0}, :" , customerName))
.Table(t => t.Column( "" , 70).Column( ", ." , 30),
r => r.Row(itemName1, itemSumm1)
.Row(itemName2, itemSumm2)
.Row(w => w.Right.Bold.Text( ":" ), w=>w.Center.Bold.Underlined.Text(summ))
));
File .WriteAllBytes( string .Format( @"D:\Word.docx" ), docxDocument.ToArray());
}
}
* This source code was highlighted with Source Code Highlighter .
private static void Main()
{
using ( var docxDocument = new DocxDocument(SimpleTemplate.EmptyWordFile))
{
var builder = new DocxDocumentBuilder(docxDocument);
builder
.Tag(SimpleTemplate.ContentTagName,
x => x.Left.Paragraph( " ..." )
.Right.Paragraph(z => z.Placeholder( "SIGNER_NAME" , " .." )));
File .WriteAllBytes( string .Format( @"D:\Word.docx" ), docxDocument.ToArray());
}
using ( var docxDocument = new DocxDocument( File .ReadAllBytes( @"D:\Word.docx" )))
{
var builder = new DocxDocumentBuilder(docxDocument);
builder
.Placeholder( "SIGNER_NAME" , x => x.Text( " .." ));
File .WriteAllBytes( string .Format( @"D:\Word.docx" ), docxDocument.ToArray());
}
}
* This source code was highlighted with Source Code Highlighter .
private static void Main()
{
using ( var docxDocument = new DocxDocument())
{
docxDocument.AddOpenCloseTag( "CONTENT" );
var builder = new DocxDocumentBuilder(docxDocument);
builder
.Tag( "CONTENT" , x => x.Left.Paragraph( " ..." ));
File .WriteAllBytes( string .Format( @"D:\Word.docx" ), docxDocument.ToArray());
}
}
* This source code was highlighted with Source Code Highlighter .
builder.Tag( "CONTENT" , x => x.Paragraph( " " .Bold() + " " .Italic() + " " .Underlined() + "" ));
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/125903/