Lazy loading with LINQ Reporting Engine

Good morning,
we use Aspose.Words via LINQ Reporting Engine, we let the customer create their own templates navigating from table to table present in provided DataSet. At the moment we provide DataSets based on report context, but the idea is to give them a bigger (whole) DataSet to let them know which are the available tables to use, but we have a question:

is it possible to easily have the list of “tables” used inside the Document template ?

This will let us perform a “lazy”-load of data, filling only the minimun DataSet needed by template instead of passing a huge amount of data that could be useless, considering template code.

Thanks a lot in advance for any information you can give us !
Have a nice day… and Happy Xmas holidays :wink:

@Jackomino Unfortunately, LINQ Reporting Engine does not provide a functionality to get a list of template fields from a document at the moment. This feature was already requested, it was logged as WORDSNET-17454, but for now, its development is postponed. You will be notified through the forum thread, once it is implemented.

As a workaround, to find contents of simple expression tags, you can use Range.Replace functionality on a template document (without actual replacing) as follows:

DocumentBuilder builder = new DocumentBuilder();
builder.Write("Some text <<[Column1]>>, more text <<[Column2]>>, and some more text.");

ColumnNameCollector collector = new ColumnNameCollector();
Regex regex = new Regex(@"<<\[(.*?)\]>>");

builder.Document.Range.Replace(regex, "", new FindReplaceOptions(collector));

foreach (string columnName in collector.ColumnNames)
    Console.WriteLine(columnName);

Console.WriteLine(builder.Document.GetText().Trim()); // Prints the same text, it is not replaced.
internal class ColumnNameCollector : IReplacingCallback
{
    public ReplaceAction Replacing(ReplacingArgs args)
    {
        ColumnNames.Add(args.Match.Groups[1].Value);

        // We do not want to replace anything, so skip the match.
        return ReplaceAction.Skip;
    }

    internal List<string> ColumnNames { get; } = new List<string>();
}

Thanks a lot for the information.
We are analyzing how to reduce the complexity of sharing information with the template user/composer, maybe we can collect information on tables when saving the template and use the information when the report is filled…

Thanks a lot again for your support
Jack

1 Like