Hello there,
I did add a sample Project to the Issue, i am going to describe what it does/should do and why.
The Situation:
I have a Tables in a Document, each with 2 Columns. The heading row will always contain the same Strings ("#" and “Req”), i will search for these strings.
if the table does fit these strings, i extract them with the ExtractContent(startPar, endPar) Method i found on this site.
I create “ReqHeading” Objects from my Tables (and the overlaying heading). These Objects contain the text of the Heading aswell as the tables as aspose objects (Nodes) to keep their formatting.
These ReqHeadings will be added to a ReviewObject that needs to contain the DocumentTitle and all Headings including the underlaying tables. I pass the reviewObject to the CreateReviewDocument(rObj) Method which is going to generate the new Document.
In the newly generated Document, the tables need to look a bit different. except for the heading row, every row needs to have a second row under them (this is needed for a comment on the above row) i implemented this by adding 3 new Cells and merge them afterwards. A new collumn is added to each table, the column heading is “Fulfilled” and the default value of the cells under it is “ToDo”. At the end, the Document needs to be saved.
When i ran the application everything worked, but i had an empty paragraph at the start of each cell and at the end of some cells. (Fulfilled & Todo cells).
So i added this piece of code to remove the empty paragraphs:
// I import the previously extracted nodes here to keep formatting
var ni = new NodeImporter(srcDoc, ReviewDoc, ImportFormatMode.KeepSourceFormatting);
cell.Paragraphs.Add(ni.ImportNode(child, true));
// i will look at the first paragraph if it’s empty (containing the "\r" character that symbolises a new line) i will delete it.
if (cell.Paragraphs[0].GetText() == "\r")
{
cell.Paragraphs[0].Remove();
}
// then im goint to Move the Cursor to the end of the cell because the next call of "builder.InsertCell" is going to return null if i don’t (i think this is because the Cursor position is not set anymore because of deleting a paragraph)
builder.MoveTo(cell.LastParagraph);
Now when i run the Application it will work fine, but the result comes out a bit weird.
The Merged cells are only the width of the first column and whenever there are BulletLists the Bullets are all across the row or do not appear at all.
Now my Questions:
- Do i set the Cursor to the Right position after deleting the paragraph?
- If not, where do i need to set it?
- If yes, what else do i need to tweak?
- Why does this affect the next row’s width and how do i prevent this from happening?
Thanks for your Help.