Hello Alexey,
Your sample works very well. But, I have some issues when using it as shown below.
// =========== start of code ================
using Aspose.Words.Reporting;
using DataObjects;
using System.Text;
using System.Text.Json;
using System.Xml.Linq;
Aspose.Words.License license = new Aspose.Words.License();
long i = 1;
string k = i.ToString(); // long integer converted to string
// Datasources
//string json = "{ \"CommonInfo\": { \"Param1\": \"First\", \"Param2\": \"Second\", \"Param3\": \"Third\", \"Param4\": \"Fourth\", \"Param5\": \"Fifth\", \"Param6\": \"Sixth\" }}";
string json = $$"""
{
"CommonInfo":
{
"Param1": "First",
"Param2": "Second",
"Param3": "{{k}}", // issue here
"Param4": "Fourth",
"Param5": "Fifth",
"Param6": "Sixth"
}
}
""";
JsonDataSource ds = new JsonDataSource(new MemoryStream(Encoding.UTF8.GetBytes(json)));
Aspose.Words.Document doc = new Aspose.Words.Document("C:\\aspose\\sample - copy\\in.docx");
ReportingEngine engine = new ReportingEngine();
engine.Options = ReportBuildOptions.RemoveEmptyParagraphs;
engine.KnownTypes.Add(typeof(MyClass));
engine.BuildReport(doc, ds, "CommonInfo");
string outputPath = "C:\\aspose\\sample - copy\\out.docx";
doc.Save(outputPath);
// ========== end of code ==============
As you can see above, in the json string, I have for Param3, I am assigning a string “k” converted from long type.
When I execute the above code, I get the below error:
An error has been encountered at the end of expression 'graphic = MyClass.GetGraphics("Overview", CommonInfo.Param1, CommonInfo.Param2, CommonInfo.Param3, CommonInfo.Param4, CommonInfo.Param5, CommonInfo.Param6)]>'. Can not resolve method 'GetGraphics' on type 'MyClass'.
Same issue noticed if the json string is as shown below.
string json = "{ \"CommonInfo\": { \"Param1\": \"First\", \"Param2\": \"Second\", \"Param3\": \"1\", \"Param4\": \"Fourth\", \"Param5\": \"Fifth\", \"Param6\": \"Sixth\" }}";
I have uploaded the json view, Please help with some pointers
Regards,