Pārlūkot izejas kodu

Fixed an issue with Paragraphs inside Tables not knowing which document they belong to.

master
coffeycathal_cp pirms 15 gadiem
vecāks
revīzija
cd4dc19ae0
3 mainītis faili ar 38 papildinājumiem un 7 dzēšanām
  1. 29
    4
      ConsoleApplication3/Program.cs
  2. 3
    1
      DocX/DocX.cs
  3. 6
    2
      DocX/Paragraph.cs

+ 29
- 4
ConsoleApplication3/Program.cs Parādīt failu

@@ -11,14 +11,39 @@ namespace ConsoleApplication3
{
static void Main(string[] args)
{
// Create a new document.
// Create a document.
using (DocX document = DocX.Create(@"Test.docx"))
{
document.InsertParagraph("I cant believe this took so long.");
// Add a Table to this document.
Table table = document.AddTable(2, 3);
// Add a Hyperlink into this document.
Hyperlink h = document.AddHyperlink("Google", new Uri("http://www.google.com"));
// Add an Image into this document.
Novacode.Image i = document.AddImage(@"C:\Users\cathal\Desktop\Logo.png");
// Create a Picture (Custom View) of this Image.
Picture p = i.CreatePicture();
p.Rotation = 10;
// Specify some properties for this Table.
table.Alignment = Alignment.center;
table.Design = TableDesign.LightShadingAccent2;
// Insert the Table into the document.
Table t1 = document.InsertTable(table);
// Add content to this Table.
t1.Rows[0].Cells[0].Paragraphs.First().AppendHyperlink(h).Append(" is my favourite search engine.");
t1.Rows[0].Cells[1].Paragraphs.First().Append("This text is bold.").Bold();
t1.Rows[0].Cells[2].Paragraphs.First().Append("Underlined").UnderlineStyle(UnderlineStyle.singleLine);
t1.Rows[1].Cells[0].Paragraphs.First().Append("Green").Color(Color.Green);
t1.Rows[1].Cells[1].Paragraphs.First().Append("Right to Left").Direction = Direction.RightToLeft;
t1.Rows[1].Cells[2].Paragraphs.First().AppendPicture(p);
// Save the document.
document.Save();
}
}// Release this document from memory.
}
}
}

+ 3
- 1
DocX/DocX.cs Parādīt failu

@@ -1020,8 +1020,9 @@ namespace Novacode
/// </example>
public new Table InsertTable(Table t)
{
t = base.InsertTable(t);
t.mainPart = mainPart;
return base.InsertTable(t);
return t;
}
/// <summary>
@@ -1714,6 +1715,7 @@ namespace Novacode
);
Hyperlink h = new Hyperlink(this, i);
h.Text = text;
h.Uri = uri;

+ 6
- 2
DocX/Paragraph.cs Parādīt failu

@@ -237,7 +237,9 @@ namespace Novacode
/// </example>
public override Table InsertTableBeforeSelf(Table t)
{
return base.InsertTableBeforeSelf(t);
t = base.InsertTableBeforeSelf(t);
t.mainPart = mainPart;
return t;
}
private Direction direction;
@@ -631,7 +633,9 @@ namespace Novacode
/// </example>
public override Table InsertTableAfterSelf(Table t)
{
return base.InsertTableAfterSelf(t);
t = base.InsertTableAfterSelf(t);
t.mainPart = mainPart;
return t;
}
/// <summary>

Notiek ielāde…
Atcelt
Saglabāt