We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert new rows into a table causes format to be wrong everywhere else

hi - I am using bookmarks to insert data into ms word. Everything works fine until I use this (commented out because it affects all the other tables in the same and subsequent documents)
Could you tell me why please?

        //        //builder.MoveToBookmark(bookMark);
        //        Aspose.Words.Tables.Table table = doc.document.FirstSection.Body.Tables[2];
        //        int additionalRows = aDs.Tables[0].Rows.Count - table.Rows.Count + 1;
        //        if (additionalRows > 0)
        //        {
        //            for (int i = 0; i < additionalRows; i++)
        //            {
        //                Aspose.Words.Tables.Row clonedRow = (Aspose.Words.Tables.Row)table.LastRow.Clone(true);
        //                foreach (Cell cell in clonedRow.Cells)
        //                {
        //                    cell.RemoveAllChildren();
        //                    cell.EnsureMinimum();                                
        //                }
        //                table.Rows.Add(clonedRow);
        //            }
        //        }
        //        foreach (Cell cell in table.LastRow.Cells)
        //        {
        //            cell.CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.Thick;
        //            cell.CellFormat.Borders.Bottom.LineWidth = 1.5;
        //        }

        //        for (int row = 0; row < aDs.Tables[0].Rows.Count; row++)
        //        {
        //            string tradeDate = DateTime.Parse(aDs.Tables[0].Rows[row]["trade_date"].ToString()).ToString("dd-MMM-yyyy");
        //            string inflow = Math.Abs(Double.Parse(aDs.Tables[0].Rows[row]["flow"].ToString())).ToString("###,###,###,##0");
        //            string flowType = aDs.Tables[0].Rows[row]["trans_type"].ToString();

        //            builder.MoveToCell(2,row+1,0,-1); // move to the beginning of the cell 
        //            builder.Font.Name = "Arial";
        //            builder.Font.Size = 10;
        //            builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
        //            builder.InsertHtml(tradeDate, true);
        //            if (flowType == "SUBSCRIPTION")
        //            {
        //                builder.MoveToCell(2, row + 1, 1, -1);
        //                builder.Font.Name = "Arial";
        //                builder.Font.Size = 10;
        //                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;

        //                builder.MoveToCell(2, row + 1, 2, -1);
        //                builder.Font.Name = "Arial";
        //                builder.Font.Size = 10;
        //                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
        //                builder.InsertHtml("N/A", true);
        //            }
        //            else
        //            {
        //                builder.MoveToCell(2, row + 1, 1, -1);
        //                builder.Font.Name = "Arial";
        //                builder.Font.Size = 10;
        //                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
        //                builder.InsertHtml("N/A", true);

        //                builder.MoveToCell(2, row + 1, 2, -1);
        //                builder.Font.Name = "Arial";
        //                builder.Font.Size = 10;
        //                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
        //                builder.InsertHtml(inflow, true);
        //            }
                    
        //        }
        //    }
        //    else
        //    {
        //        for (int col = 0; col < 3; col++)
        //        {
        //            builder.MoveToCell(2, 0, col, 0); // move to the beginning of the cell 
        //            builder.Font.Name = "Arial";
        //            builder.Font.Size = 10;
        //            builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
        //            builder.InsertHtml("N/A", true);
        //        }
        //    }
        //}
        //builder.CellFormat.ClearFormatting();
        //builder.ParagraphFormat.ClearFormatting();

Hi Philip,

Thanks for your inquiry. It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple application (for example a Console
    Application Project
    ) that demonstrates the code (Aspose.Words code) you used to generate
    your output document

  • Please attach the output Word file that shows the undesired behavior.
  • Please
    attach your target Word document showing the desired behavior. You can
    use Microsoft Word to create your target Word document. I will
    investigate as to how you are expecting your final document be generated
    like.

Unfortunately,
it is difficult to say what the problem is without the Document(s) and
simplified application. We need your Document(s) and simple project to
reproduce the problem. As soon as you get these pieces of information to
us we’ll start our investigation into your issue.