Allowing InsertColumn method take into account merged cells for multiple
row add columns where the count of cells is less than the index but is
not less table column count
Fixed the problem with setting the column width for the whole table.
Without this patch the SetColumnWidth method throws the
NullReferenceException if the column widths haven't been initialized
before. Added the test to check the issue and to see whether it's fixed.
- MergeCellsInRow - allow for merging the rows where the columns don't match (for instance, merge the last column of a row with 6 elements and a row with 3 elements will merge the last column of the row with too few elements)
- this is a specific case that I needed... others may need it as well, but I've got a separate branch with this change so it's up to you
Container.cs (and baseclasses)
- Moved PackagePart to the base class - found an issue where images in a table contained in the header or footer wouldn't display, this keeps track of what part of the doc and passes it to child things, (like inserting a table to a paragraph in the footer will have the correct part)
- Add a deep search for paragraphs.. This is to find a bookmark within a textbox or other art.. since a paragraph will wind up with a child paragraph.. (if you are searching for a bookmark like that the second one is the "right" one)
Few changes were made to allow to set the column widths for a table, on table level instead for each single cell.
The following methods/properties have been added:
- ColumnWidths - Returns a list (Of Double) with the width of all columns
- GetColumnWidth - Returns the width to a given single column index
- SetColumnWidth - Sets the column width to a given index
Property "AutoFit" has been modified to use the fixed table width; AutoFit will be set to "Fixed" if method "SetColumnWidth" is called.
Furthermore the enumeration: "AutoFit" got an addtional value: "Fixed".
Some warnings:
If you apply a width on table level; the cell width value will be removed for all table cells!
This one is a performance boost for cases where docs have lots of paragraphs inserted (through tables or whatever)...
In the case that I found the issue, I was creating a report that added a lot of plain text paragraphs followed by lots of tables.. (creating a 40 page doc)
(the fix is to avoid using the Paragraphs collection to get the one that was just added.. it fixes the reference to the "mainPart" so things like images that are added still work... )
All unit tests pass after this test (did have to fix some case issues with the one that does text replacements though)
Includes:
-fix for default column widths (also works when column widths are not specified) - issue that was breaking tables with more than 14 cols
-New table method to set the widths for variable row tables... you can call Table.SetWidths(float [] yourWidthsInPixels) then for each row added those cols will have that width applied.. can help clean up some code.. also caches the column count for performance..
- Change for DocX that turns on zip compression for the parts of the doc (created docs are as small as re-saved versions from word now)
Previously created TableBorder class has an error in setting table border colors. The generated colors are invalid according to the DOCX specification.
Fixed this by using the _Extensions methods.
Patch provided by lckuiper
Adds the option to set the BreakAcrossPages property, which corresponds to the "Allow row to break across pages" property in Word: http://fiveminutelessons.com/learn-microsoft-word/stop-table-rows-microsoft-word-splitting-across-pages
1. override InsertTable(int rowCount, int columnCount) method in Table Cell because of bug.
Cell need paragraph in the end.
2. InsertTableBeforeSelf(Table t) behaviour changed, now it returns completely new table copied from parameter table.
3. InsertParagraphAfterSelf(Paragraph p) behaviour changed, now it returns completely new paragraph copied from parameter paragraph, but only in case for this is Paragraph
4. InsertTableAfterSelf(Table t) the same as for InsertTableBeforeSelf behaviour changed, now it returns completely new table copied from parameter table.
P.S. Look please my //IMPORTANT notes in code.
Refactor the Table class: RowCount, ColumnCount, Rows properties and Insert/Remove methods. Also refactor CreateTable method - extract the same method CreateTableCell. Add powerfull unit test for this.
This projects contains many of the examples upload on my blog.
Each time docx is released, I will update these examples so as they still work regardless of API changes.
Added unit tests.
Removed overloads which confussed API.
Its now possible to create one Picture and insert it into the main document, headers and footers.
Removed Rebuild[Images, Pictures, Tables, CustomProperties], this work is now done by getter functions, this is a much cleaner approach.
Added Getter and Setter functions for Hyperlink. Also added Hyperlink properties for Document, Paragraph, Table, Row and Cell.
Added similar functions for Pictures.
----------
Created an abstract class called DocXElement and made every document element such as {Table, Row, Cell, Paragraph, Run, Text, etc} extend it.
Created an abstract class InsertBeforeOrAfter which is derived from DocXElement. This provides functions for inserting, page breaks, Paragraphs and Tables before and after self.
Moved Text and Run inside Paragraph, keep consistancy with Table which contains Row and Cell.
To Do: Investigated why the Picture class had two internal constructors. I removed one.
Added a _ to each .cs file that does not contain instanceable types, {Enumerations.cs, Extensions.cs, etc}
Bugs fixed
----------
Cell had a parameter Paragraph, this was incorrect as paragraphs can contain multiple Paragraphs. Now it returns a List<Paragraph>
InsertDocProperty now returns a DocProperty instead of void.
New features
------------
InsertDocProperty now contains overloads for the parameter track changes.
Cell now contains a Shading property, this can be used to set the background color of a cell.