output.json
[
{
"Name": "Monday",
"Sections": [
{
"Name": "CAT1",
"StackedCharts": [
[
{
"Name": "A",
"Value": 1
},
{
"Name": "B",
"Value": 0
},
{
"Name": "C",
"Value": 0
}
]
]
},
{
"Name": "CAT2",
"StackedCharts": [
[
{
"Name": "A",
"Value": 0.9
},
{
"Name": "B",
"Value": 0.1
},
{
"Name": "C",
"Value": 0
}
]
]
}
]
},
{
"Name": "Tuesday",
"Sections": [
{
"Name": "CAT1",
"StackedCharts": [
[
{
"Name": "A",
"Value": 1
},
{
"Name": "B",
"Value": 0
},
{
"Name": "C",
"Value": 0
}
]
]
},
{
"Name": "CAT2",
"StackedCharts": [
[
{
"Name": "A",
"Value": 0.9
},
{
"Name": "B",
"Value": 0.1
},
{
"Name": "C",
"Value": 0
}
]
]
}
]
}
]
Main.cs
using Aspose.Words;
using Aspose.Words.Reporting;
using System.Text.Json;
using Document = Aspose.Words.Document;
string jsonString = File.ReadAllText(@"C:\Users\output.json");
var listData = JsonSerializer.Deserialize<List<AllSections>>(jsonString);
Export export = new Export();
export.Details = listData;
//// Input directory
License license = new License();
var licensePath = "Aspose.Words.NET.lic";
license.SetLicense(licensePath);
string dataDir = @"C:\Users\inputq.docx";
// Build Aspose
Document doc = new Document(dataDir);
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, export, "ds");
// START CHECKING OF EMPTY PAGE
var totalPages = doc.PageCount; // <------ ERROR LINE
for (int i = 0; i < totalPages; i++)
{
Document onePageDoc = doc.ExtractPages(i, 1); // <------ ERROR LINE
}
// Output directory
dataDir = @"C:\Users\AsposeWord_Test_Output.docx";
// Save the output
doc.Save(dataDir);
Console.WriteLine("Completed.");
public class Export
{
public List<AllSections> Details { get; set; }
}
public class AllSections
{
public string Name { get; set; }
public List<Sections> Sections { get; set; }
}
public class Sections
{
public string Name { get; set; }
public List<List<StackedCharts>> StackedCharts { get; set; }
}
public class StackedCharts
{
public string Name { get; set; }
public double Value { get; set; }
public StackedCharts()
{
}
}
I keep hit Index was outside the bounds of the array. when try to generate the report. I have attached the json output file, and the report template.
inputq.docx (28.4 KB)
Expected_Output.docx (26.6 KB)