Will there be any difference in report generation time if Word template coming from SharePoint Instead of current directory

We are passing below way to pass stream to aspose received from the SharePoint.
Please see if you found any issue

@alexey.noskov

MemoryStream streamPassedToAspose = new MemoryStream();
// SharePoint code
ClientResult<Stream> binaryStream = file.OpenBinaryStream();
clientContext.ExecuteQuery();
//Copy stream
await binaryStream.Value.CopyToAsync(streamPassedToAspose);

@Gauravgarg01 Once you execute the following:

Document doc = new Document(streamPassedToAspose);

Whole document is loaded into the DOM and is not connected to the original stream file, or other source.

Have you tried (just for testing) saving the document loaded from SharePoint to file and then loading it into Aspose.Words? Does it make any difference?

I do not try - saving the document loaded from SharePoint to file and then loading it into Aspose.Words

As it might can increse the time for us

@alexey.noskov

@Gauravgarg01 I mean save the document loaded from SharePoint to file for testing purposes to measure the report generation time.

yes, tried below are the number

@alexey.noskov

@Gauravgarg01 You have shared the same output as earlier. I mean something like this:

// Load the file into a stream From shapepoint.
MemoryStream docStream = // Load from SharePoint....
// Save the loaded stream to file.
File.WriteAllBytes("file path.docx", docStream.ToArray());

// Open document from file.
Document doc = new Document("file path.docx");
// .....

not tried this
@alexey.noskov

Hii @alexey.noskov
I tried same now it’s taking more time to build the report

3000ms

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
reportingEngine.BuildReport(templateDocument, documentJsonData, "d");
var a = stopwatch.ElapsedMilliseconds;

@Gauravgarg01 So now in both test cases the template is loaded from file and report generation time is different. Could you please attach bot templates - original template loaded from file and the template loaded from SharePoint? Are these template binary the same?

@alexey.noskov
Please find attach sharepoint onesample.docx (36.8 KB)

please find one on local
@alexey.noskov

sample.docx (36.8 KB)

@Gauravgarg01 Unfortunately, I cannot reproduce the problem I have used the following code for testing:

private static void Test(string inPath, string dataPath, string outPath)
{
    JsonDataSource documentJsonData = new JsonDataSource(dataPath);

    Stopwatch stopwatch = new Stopwatch();
    stopwatch.Start();
    // Load the file into a stream.
    Stream docStream = File.OpenRead(inPath);
    Console.WriteLine($"Stream load time: {stopwatch.ElapsedMilliseconds}ms");

    stopwatch.Restart();
    // Open document from stream
    Document doc = new Document(docStream);
    Console.WriteLine($"Document load time: {stopwatch.ElapsedMilliseconds}ms");

    stopwatch.Restart();
    // But the report
    ReportingEngine engine = new ReportingEngine();
    engine.BuildReport(doc, documentJsonData, "d");
    Console.WriteLine($"Report generation time: {stopwatch.ElapsedMilliseconds}ms");

    stopwatch.Restart();
    // Save the output.
    doc.Save(outPath);
    Console.WriteLine($"Document save time: {stopwatch.ElapsedMilliseconds}ms");
}

Run it with the following parameters:

Test(@"C:\Temp\local.docx", @"C:\Temp\data.json", @"C:\Temp\out_local.docx");

output:

Stream load time: 0ms
Document load time: 495ms
Report generation time: 239ms
Document save time: 341ms

Then run test with the following parameters:

Test(@"C:\Temp\sharepoint.docx", @"C:\Temp\data.json", @"C:\Temp\out_sharepoint.docx");

output:

Stream load time: 0ms
Document load time: 495ms
Report generation time: 228ms
Document save time: 336ms

As you can see report generation time is the same on my side.

Instead of passing file directly can you pass Stream ?

@Gauravgarg01 In the test file is read to stream and document is created from stream:

Stream docStream = File.OpenRead(inPath);

Aspose.word using SharePoint

@Gauravgarg01 The article describes a basic technique to work with documents stored in SharePoint. But accessing SharePoint specific information is out of Aspose.Words scope. You should check with SharePoint API to get a version specific document.