Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Program.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Novacode;
  6. using System.Drawing;
  7. namespace ConsoleApplication3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // Create a document.
  14. using (DocX document = DocX.Create(@"Test.docx"))
  15. {
  16. // Add a Table to this document.
  17. Table table = document.AddTable(2, 3);
  18. // Add a Hyperlink into this document.
  19. Hyperlink h = document.AddHyperlink("Google", new Uri("http://www.google.com"));
  20. // Add an Image into this document.
  21. Novacode.Image i = document.AddImage(@"C:\Users\cathal\Desktop\Logo.png");
  22. // Create a Picture (Custom View) of this Image.
  23. Picture p = i.CreatePicture();
  24. p.Rotation = 10;
  25. // Specify some properties for this Table.
  26. table.Alignment = Alignment.center;
  27. table.Design = TableDesign.LightShadingAccent2;
  28. // Insert the Table into the document.
  29. Table t1 = document.InsertTable(table);
  30. // Add content to this Table.
  31. t1.Rows[0].Cells[0].Paragraphs.First().AppendHyperlink(h).Append(" is my favourite search engine.");
  32. t1.Rows[0].Cells[1].Paragraphs.First().Append("This text is bold.").Bold();
  33. t1.Rows[0].Cells[2].Paragraphs.First().Append("Underlined").UnderlineStyle(UnderlineStyle.singleLine);
  34. t1.Rows[1].Cells[0].Paragraphs.First().Append("Green").Color(Color.Green);
  35. t1.Rows[1].Cells[1].Paragraphs.First().Append("Right to Left").Direction = Direction.RightToLeft;
  36. t1.Rows[1].Cells[2].Paragraphs.First().AppendPicture(p);
  37. document.Save();
  38. }// Release this document from memory.
  39. }
  40. }
  41. }