Dear Guy
Recently, we are trying to prepare an API for merging word reports. However, when the report exceeds 150 pages, we encounter a performance problem.
When we copy the table as attached file 25 times, the document is nearly 50 pages. We perform the same operation three times and finally merge the three executed documents into one document, the number of pages will be close to 150, The whole process takes more than 7 minutes. This response speed is far from meeting the requirements for web API. Here is our code for copying tables and merging sub reports.
we hope to get the corresponding guidance, thank you
version of component Aspose.Word : 19.12.0.0
program language : C#
bellow code for copying the table :
private Row CopyRow(Row sourceRow)
{
Row row = sourceRow.Clone(false) as Row;
foreach (Cell cell in sourceRow.Cells)
{
row.Cells.Add(this.CopyCell(cell));
}
return row;
}
private Cell CopyCell(Cell sourceCell)
{
Cell cell = sourceCell.Clone(false) as Cell;
foreach (Node nd in sourceCell.ChildNodes)
{
if (nd.NodeType == NodeType.Paragraph)
{
cell.AppendChild(this.CopyParagraph((nd as Paragraph)));
}
else if (nd.NodeType == NodeType.Table)
{
Node tnd = cell.Document.ImportNode(nd, true);
cell.AppendChild(tnd);
}
}
return cell;
}
private Paragraph CopyParagraph(Paragraph sourceParagraph,)
{
if (sourceParagraph == null)
{
return null;
}
//Create a new paragraph
Paragraph newParagraph = AsposeHelper.CopyParagraphWithoutChild(sourceParagraph);
newParagraph.ParagraphFormat.Style = sourceParagraph.ParagraphFormat.Style;
//Copy child nodes
foreach (Node node in sourceParagraph.ChildNodes)
{
//Copy a new bookmark start or end object
if (node.NodeType == NodeType.BookmarkStart || node.NodeType == NodeType.BookmarkEnd)
{
//Get old bookmark name
string bookmarkName;
if (node.NodeType == NodeType.BookmarkStart)
{
bookmarkName = ((BookmarkStart)node).Name;
}
else
{
bookmarkName = ((BookmarkEnd)node).Name;
}
//New bookmark name
string newName = BookmarkOperator.CopyBookmarkName(node.Document, bookmarkName);
}
//Create a new bookmark start or end
Node newNode;
if (node.NodeType == NodeType.BookmarkStart)
{
//Create a new bookmark start
newNode = new BookmarkStart(node.Document, newName);
}
else
{
//Create a new bookmark end
newNode = new BookmarkEnd(node.Document, newName);
}
//Add to new paragraph
newParagraph.AppendChild(newNode);
}
//Copy other nodes
else
{
Node newNode = node.Clone(true);
newParagraph.AppendChild(newNode);
}
return newParagraph;
}