v0.3.0
What's Changed
- Update table width example by @hisuwh in #41
- Adds AddBreak() method to Paragraphs by @PrzemyslawKlys in #39
- Add ability to add nested tables (add table into cell of an existing table) by @PrzemyslawKlys in #35
- Implement Save and Load to/from Stream by @hisuwh in #43
New Contributors
Details
-
Update DocumentFormat.OpenXml from 2.16.0 to 2.18.0
-
Update SixLabors.ImageSharp to 2.1.3
-
Adds ability to add nested table into existing table.
internal static void Example_NestedTables(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with nested tables");
string filePath = System.IO.Path.Combine(folderPath, "Document with Nested Tables.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph = document.AddParagraph("Lets add table ");
paragraph.ParagraphAlignment = JustificationValues.Center;
paragraph.Bold = true;
paragraph.Underline = UnderlineValues.DotDash;
WordTable wordTable = document.AddTable(4, 4, WordTableStyle.GridTable1LightAccent1);
wordTable.Rows[0].Cells[0].Paragraphs[0].Text = "Test 1";
wordTable.Rows[1].Cells[0].Paragraphs[0].Text = "Test 2";
wordTable.Rows[2].Cells[0].Paragraphs[0].Text = "Test 3";
wordTable.Rows[3].Cells[0].Paragraphs[0].Text = "Test 4";
wordTable.Rows[0].Cells[0].AddTable(3, 2, WordTableStyle.GridTable2Accent2);
wordTable.Rows[0].Cells[1].AddTable(3, 2, WordTableStyle.GridTable2Accent5, true);
document.Save(openWord);
}
}
-
Adds
NestedTables
property for WordTable to get all nested tables for a given table -
Adds
HasNestedTables
property for WordTable to know if the table has nested tables -
Adds
IsNestedTable
property for WordTable to know if the table is nested table -
Adds
ParentTable
property for WordTable to find the parent table if the table is nested -
Added some summaries to multiple tables related to methods/properties
-
Adds
TablesIncludingNestedTables
property to Sections and Document to make it easy to find all tables within the document and manipulate them -
Solves an issue with a different word break required #37
public static void Example_BasicWordWithBreaks(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with paragraph & breaks");
string filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithParagraphsAndBreaks.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph1 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
var paragraph2 = document.AddParagraph("Adding paragraph2 with some text and pressing SHIFT+ENTER");
paragraph2.AddBreak();
paragraph2.AddText("Continue1");
paragraph2.AddBreak();
paragraph2.AddText("Continue2");
var paragraph3 = document.AddParagraph("Adding paragraph3 with some text and pressing ENTER");
document.Save(openWord);
}
}
Additionally:
- Renames WordPageBreak to WordBreak to accommodate all Breaks, and not only PageBreak
- BREAKING CHANGE Removing WordBreak (or WordPageBreak) no longer by default removes paragraph, but instead requires bool set to true
document.Breaks[0].Remove();
document.Breaks[0].Remove(includingParagraph: true);
- Add new
IsBreak
property for WordParagraph - Add
Breaks
property for WordDocument - Implement Save and Load to/from Stream #43
Full Changelog: v0.2.1...v0.3.0