Releases: EvotecIT/OfficeIMO
v0.4.5
What's Changed
- Merge instructions distributed over runs to field string by @byteSamurai in #95
Full Changelog: v0.4.4...v0.4.5
v0.4.4
What's Changed
- Fixes HyperLink AddStyle not being applied by @PrzemyslawKlys in #93
Full Changelog: v0.4.3...v0.4.4
v0.4.3
What's Changed
- Improve tests, fix HyperLink order, add method ValidateDocument() by @PrzemyslawKlys in #87
- Fix badges by @rstm-sf in #88
- Ability to insert table before/after paragraph by @PrzemyslawKlys in #92
- Paragraph.AddTableAfter()
- Paragraph.AddTableBefore()
internal static void Example_TablesAddedAfterParagraph(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with width and alignment");
string filePath = System.IO.Path.Combine(folderPath, "Document with Table Alignment.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph = document.AddParagraph("Lets add table with some alignment ");
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";
var paragraph1 = document.AddParagraph("Lets add another table showing text wrapping around, but notice table before and after it anyways, that we just added at the end of the document.");
WordTable wordTable1 = document.AddTable(4, 4, WordTableStyle.GridTable1LightAccent1);
wordTable1.Rows[0].Cells[0].Paragraphs[0].Text = "Test 1";
wordTable1.Rows[1].Cells[0].Paragraphs[0].Text = "Test 2";
wordTable1.Rows[2].Cells[0].Paragraphs[0].Text = "Test 3";
wordTable1.Rows[3].Cells[0].Paragraphs[0].Text = "Test 4";
wordTable1.WidthType = TableWidthUnitValues.Pct;
wordTable1.Width = 3000;
wordTable1.AllowTextWrap = true;
var paragraph2 = document.AddParagraph("This paragraph should continue but next to to the table");
document.AddParagraph();
document.AddParagraph();
var paragraph3 = document.AddParagraph("Lets add another table showing AutoFit");
WordTable wordTable2 = document.AddTable(4, 4, WordTableStyle.GridTable1LightAccent1);
wordTable2.Rows[0].Cells[0].Paragraphs[0].Text = "Test 1";
wordTable2.Rows[1].Cells[0].Paragraphs[0].Text = "Test 2";
wordTable2.Rows[2].Cells[0].Paragraphs[0].Text = "Test 3";
wordTable2.Rows[3].Cells[0].Paragraphs[0].Text = "Test 4";
paragraph1.AddParagraphBeforeSelf();
paragraph1.AddParagraphAfterSelf();
var table3 = paragraph1.AddTableAfter(4, 4, WordTableStyle.GridTable1LightAccent1);
table3.Rows[0].Cells[0].Paragraphs[0].Text = "Inserted in the middle of the document after paragraph";
var table4 = paragraph1.AddTableBefore(4, 4, WordTableStyle.GridTable1LightAccent1);
table4.Rows[0].Cells[0].Paragraphs[0].Text = "Inserted in the middle of the document before paragraph";
document.Save(openWord);
}
}
Full Changelog: v0.4.2...v0.4.3
v0.4.2
What's Changed
- The order of paragraph properties and runs does matter by @PrzemyslawKlys in #83
- This release fixes LISTS. Sorry for that!
Full Changelog: v0.4.1...v0.4.2
v0.4.1
What's Changed
- Extending available FieldCodes and allow setting parameters by @byteSamurai in #75
- Fix check IsToc for Word.Lists by @rstm-sf in #76
- Provide multi platform project config by @byteSamurai in #79
New Contributors
- @byteSamurai made their first contribution in #75
Full Changelog: v0.4.0...v0.4.1
v0.4.0
What's Changed
- Improve settings for document with PT-BR and HighAnsi chars by @PrzemyslawKlys in #56
- FontFamilyHighAnsi for document.Settings which is required for special chars
public static void Example_BasicWordWithDefaultFontChange(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with different default style (PT/BR)");
string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChangeBR.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
document.Settings.FontSize = 30;
//document.Settings.FontSizeComplexScript = 30;
document.Settings.FontFamily = "Calibri Light";
document.Settings.FontFamilyHighAnsi = "Calibri Light";
document.Settings.Language = "pt-Br";
string title = "INSTRUMENTO PARTICULAR DE CONSTITUIÇÃO DE GARANTIA DE ALIENAÇÃO FIDUCIÁRIA DE IMÓVEL";
document.AddParagraph(title).SetBold().ParagraphAlignment = JustificationValues.Center;
document.Save(openWord);
}
}
- Add Compatibility Mode, set default compatibility to the highest version by @PrzemyslawKlys in #58
- Adds default settings, including compatibility settings, math properties, and few other things that are automatically added when Microsoft Word creates a document
- Adds default web settings that are the same to what Microsoft Word does
- Sample of usage for compatiblity mode
public static void Example_BasicWordWithDefaultFontChange(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with different default style (PT/BR)");
string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChangeBR.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
document.Settings.FontSize = 30;
//document.Settings.FontSizeComplexScript = 30;
document.Settings.FontFamily = "Calibri Light";
document.Settings.FontFamilyHighAnsi = "Calibri Light";
document.Settings.Language = "pt-Br";
document.Settings.ZoomPreset = PresetZoomValues.BestFit;
Console.WriteLine(document.CompatibilitySettings.CompatibilityMode);
document.CompatibilitySettings.CompatibilityMode = CompatibilityMode.Word2013;
Console.WriteLine(document.CompatibilitySettings.CompatibilityMode);
document.CompatibilitySettings.CompatibilityMode = CompatibilityMode.None;
Console.WriteLine(document.CompatibilitySettings.CompatibilityMode);
string title = "INSTRUMENTO PARTICULAR DE CONSTITUIÇÃO DE GARANTIA DE ALIENAÇÃO FIDUCIÁRIA DE IMÓVEL";
document.AddParagraph(title).SetBold().ParagraphAlignment = JustificationValues.Center;
document.Save(openWord);
}
}
- Bump nuggets for tests and excel by @PrzemyslawKlys in #59
- Fix not saving list when saving to Stream by @rstm-sf in #62
- Add an image via stream by @rstm-sf in #51
- Add images to headers/footers/tables and other image improvements by @PrzemyslawKlys in #53
using (WordDocument document = WordDocument.Create(filePath)) {
document.BuiltinDocumentProperties.Title = "This is sparta";
document.BuiltinDocumentProperties.Creator = "Przemek";
var filePathImage = System.IO.Path.Combine(imagePaths, "Kulek.jpg");
document.AddHeadersAndFooters();
var header = document.Header.Default;
var paragraphHeader = header.AddParagraph("This is header");
// add image to header, directly to paragraph
header.AddParagraph().AddImage(filePathImage, 100, 100);
// add image to footer, directly to paragraph
document.Footer.Default.AddParagraph().AddImage(filePathImage, 100, 100);
// add image to header, but to a table
var table = header.AddTable(2, 2);
table.Rows[1].Cells[1].Paragraphs[0].Text = "Test123";
table.Rows[1].Cells[0].Paragraphs[0].AddImage(filePathImage, 50, 50);
table.Alignment = TableRowAlignmentValues.Right;
var paragraph = document.AddParagraph("This paragraph starts with some text");
paragraph.Text = "0th This paragraph started with some other text and was overwritten and made bold.";
paragraph.Bold = true;
// add table with an image, but to document
var table1 = document.AddTable(2, 2);
table1.Rows[1].Cells[1].Paragraphs[0].Text = "Test - In document";
table1.Rows[1].Cells[0].Paragraphs[0].AddImage(filePathImage, 50, 50);
// lets add image to paragraph
paragraph.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 22, 22);
}
- Rotation / VerticalFlip / HorizontalFlip / Shape work for images
internal static void Example_AddingImagesInline(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with inline images");
string filePath = System.IO.Path.Combine(folderPath, "DocumentWithInlineImages2.docx");
string imagePaths = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Images");
using (WordDocument document = WordDocument.Create(filePath)) {
var file = System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg");
var paragraph = document.AddParagraph();
var pargraphWithImage = paragraph.AddImage(file, 100, 100);
// Console.WriteLine("Image is inline: " + pargraphWithImage.Image.Rotation);
pargraphWithImage.Image.VerticalFlip = false;
pargraphWithImage.Image.HorizontalFlip = false;
pargraphWithImage.Image.Rotation = 270;
pargraphWithImage.Image.Shape = ShapeTypeValues.Cloud;
document.Save(openWord);
}
}
- Added optional Description (AltText) to images
- Added ability to wrap text around image
internal static void Example_AddingImagesSample4(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with some Images and Samples");
var filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithImagesSample4.docx");
var imagePaths = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Images");
using var document = WordDocument.Create(filePath);
var paragraph1 = document.AddParagraph("This paragraph starts with some text");
paragraph1.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200);
paragraph1.Image.Shape = ShapeTypeValues.Cube;
var paragraph2 = document.AddParagraph("Image will be placed behind text");
paragraph2.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.BehindText, "Przemek and Kulek on an image");
var paragraph3 = document.AddParagraph("Image will be in front of text");
paragraph3.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.InFrontText, "Przemek and Kulek on an image");
var paragraph5 = document.AddParagraph("Image will be Square");
paragraph5.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.Square, "Przemek and Kulek on an image");
var paragraph6 = document.AddParagraph("Image will be Through");
paragraph6.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.Through, "Przemek and Kulek on an image");
var paragraph7 = document.AddParagraph("Image will be Tight");
paragraph7.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.Tight, "Przemek and Kulek on an image");
var paragraph8 = document.AddParagraph("Image will be Top And Bottom");
paragraph8.AddImage(System.IO.Path.Combine(imagePaths, "PrzemyslawKlysAndKulkozaurr.jpg"), 200, 200, WrapImageText.TopAndBottom, "Przemek and Kulek on an image");
paragraph8.Image.Shape = ShapeTypeValues.Can;
document.Save(openWord);
}
- Fixes adding a bookmark on a document by @PrzemyslawKlys in #68
- Detect read-only before saving by @PrzemyslawKlys in #67
- Skip creation of run, which isn't needed by @PrzemyslawKlys in #69
- Add net 7.0, bump dependencies for testing by @PrzemyslawKlys in #72
Full Changelog: v0.3.1...v0.4.0
0.3.1 - 2022.10.18
- Adds BMP, GIF, PNG, TIFF image formats support #42 by rstm-sf
- Fixes issue with read only documents crashing
- Fixes watermark throwing when Headers aren't added first #46
- Fixes Adding Watermark to section that has not initialized headers will throw an error #27
- New fields added to WordSettings allowing setting of default values for the whole document for FontSize, FontSizeComplexScript, FontFamily and Language
public static void Example_BasicWordWithDefaultStyleChange(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with different default style");
string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChange.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
document.Settings.FontSize = 30;
document.Settings.FontFamily = "Calibri Light";
document.Settings.Langua...
v0.3.1
What's Changed
- Add BMP, GIF, PNG, TIFF image formats support by @rstm-sf in #42
- Fixes issue with read only documents crashing by @PrzemyslawKlys in #44
- Fixes watermark throwing when Headers aren't added first by @PrzemyslawKlys in #46
- Refactoring tests Word.Save by @rstm-sf in #50
- Allow to set default font, size, and other settings for the whole document by @PrzemyslawKlys in #48 - New fields added to WordSettings allowing setting of default values for the whole document for FontSize, FontSizeComplexScript, FontFamily and Language
public static void Example_BasicWordWithDefaultStyleChange(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with different default style");
string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChange.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
document.Settings.FontSize = 30;
document.Settings.FontFamily = "Calibri Light";
document.Settings.Language = "pl-PL";
var paragraph1 = document.AddParagraph("To jest po polsku");
var paragraph2 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
paragraph2.FontSize = 15;
paragraph2.FontFamily = "Courier New";
document.Save(openWord);
}
}
- Add
IsLastRun
andIsFirstRun
properties to WordParagraph
New Contributors
Full Changelog: v0.3.0...v0.3.1
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
v0.2.1
What's Changed
- Rearrange some Examples by @PrzemyslawKlys in #34
- Adding basic charts support by @PrzemyslawKlys in #14
Full Changelog: v0.2.0...v0.2.1
v0.2.0
What's Changed
-
Create LICENSE by @PrzemyslawKlys in #28
-
Adds new properties for Tables by @PrzemyslawKlys in #30
- Alignment
- WidthType
- Width
- ShadingFillColor
- ShadingFillColorHex
- ShadingFillPatern
- Title
- Description
- AllowOverlap
- AllowTextWrap
- ColumnWidth
- RowHeight
-
Add table positioning along with properties by @PrzemyslawKlys in #30
- LeftFromText
- RightFromText
- BottomFromText
- TopFromText
- HorizontalAnchor
- TablePositionY
- TablePositionX
- TablePositionYAlignment
- TablePositionXAlignment
- TableOverlap
-
Adds new properties for TableRow by @PrzemyslawKlys in #30
- FirstCell
- LastCell
-
Renames some properties to better name them by @PrzemyslawKlys in #30
- FirstRow -> ConditionalFormattingFirstRow
- LastRow -> ConditionalFormattingLastRow
- FirstColumn -> ConditionalFormattingFirstColumn
- LastColumn -> ConditionalFormattingLastColumn
- NoHorizontalBand -> ConditionalFormattingNoHorizontalBand
- NoVerticalBand -> ConditionalFormattingNoVerticalBand
-
Adds new properties for Table by @PrzemyslawKlys in #30
- FirstRow
- LastRow
-
Adds new methods for Table by @PrzemyslawKlys in #30
- AddComment(author, initials,comment)
-
Adds new properties for TableCell by @PrzemyslawKlys in #30
- TextDirection
Full Changelog: v0.1.7...v0.2.0