, bir Novacode.DocX nesnesi oluşturmak ve bir şablon olarak .dotx geçerlidir:
static void Main(string[] args)
{
// Insert a paragrpah:
string Title = "Hello World!";
string Header1 = "Countries in Europe";
string Header2 = "Belgium";
string Header3 = "France";
string Para1 = "Belgium, officially the Kingdom of Belgium, is a sovereign state in Western Europe bordered by France, the Netherlands, Germany, Luxembourg, and the North Sea. It is a small, densely populated country which covers an area of 30,528 square kilometres (11,787 sq mi) and has a population of about 11 million people. Straddling the cultural boundary between Germanic and Latin Europe, Belgium is home to two main linguistic groups: the Dutch-speaking, mostly Flemish community, which constitutes about 59% of the population, and the French-speaking, mostly Walloon population, which comprises 41% of all Belgians. Additionally, there is a small group of German-speakers who live in the East Cantons located around the High Fens area, and bordering Germany.";
string Para2 = "France, is a country with territory in western Europe and several overseas regions and territories. The European, or metropolitan, area of France extends from the Mediterranean Sea to the English Channel and the North Sea, and from the Rhine to the Atlantic Ocean. Overseas France include French Guiana on the South American continent and several island territories in the Atlantic, Pacific and Indian oceans. France spans 643,801 square kilometres (248,573 sq mi) and had a total population of almost 67 million people as of January 2017. It is a unitary semi-presidential republic with the capital in Paris, the country's largest city and main cultural and commercial centre. Other major urban centres include Marseille[XVI], Lyon, Lille, Nice, Toulouse and Bordeaux.";
using (MemoryStream docStream = new MemoryStream())
{
using (Novacode.DocX doc = Novacode.DocX.Create(docStream, Novacode.DocumentTypes.Document))
{
// Build the document
// apply template
doc.ApplyTemplate(@"C:\tmp\wordTemplate.dotx", false);
// insert text with styles
doc.InsertParagraph("Hello World", false).StyleName = "Titel";
doc.InsertParagraph(Header1, false).StyleName = "Kop1";//dutch for Heading1
doc.InsertParagraph(Header2, false).StyleName = "Kop2";//dutch for Heading2
doc.InsertParagraph(Para1, false).StyleName = "Standaard";//dutch for 'Standard', style 'Normal' in an English Word version
doc.InsertParagraph(Header3, false).StyleName = "Kop2";
doc.InsertParagraph(Para2, false).StyleName = "Standaard";
// Same the doc to MemoryStream
doc.SaveAs(@"C:\tmp\ExampleDoc.docx");
}
}
}
Benzer bir sorun var ama bir tabloya stil ekleyemiyor gibi görünüyor, herhangi bir fikir? –