Slow in building the Dynamic table with 25K records

Do you have any way to solve for the speed issue if I have the query return more than 25,000 records with 2 columns for each record. My code pretty simple only have:

Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(master);
builder.MoveToBookmark(bmName);
builder.StartTable();
for (each row in my dataset)
{
    for (each column in my dataset) // I only have 2 columns
{
builder.InsertCell();
builder.Write(value of the cell);
ApplySomeMinorFormatForCell();
}
    builder.EndRow();
}

It tooks me around 20 mins to return 1000 pages document.
Do you have any way faster than my way.
Thanks,
Tom.

Hi
Thanks for your inquiry. I tested your code on my side and it takes 7 seconds for generating 1000 pages document.
Also I think in this case you can use mail merge with regions. Please see the following links for more information.
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
Hope this helps.
But note that usually Aspose.Words needs about 10 times more memory for building the model than the source document size. But this is dependent on your document. So I would advise you to use several small documents instead one big document.
Best regards.

Thanks alex,
The Mail merge can help, it cut down the time to create 1000 pages document to 4 mins.