We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Printing nested objects using Aspose Cells and Smart markers

Hi,

I went through the smart-markers post. There is one topic about nested objects. But that is just for one object containing just one object inside.
I have a list of parents each with a list of child items(both parent and child are of same type). Is there a way to print parent object first, then all its nested objects below it and so on?

Eg.

Parent1Name Parent1Age
P1Child1Name P1Child1Age
P1Child2Name P1Child2Age
P1Child3Name P1Child3Age
Parent2Name Parent2Age
P2Child1Name P2Child1Age
P2Child2Name P2Child2Age
...

Hi,


Yes, I am afraid, currently you can have one object containing just one object inside it for Smart Markers’ nested objects feature, an object does not support more than one sub objects inside it. We will check if we can support this feature. I have logged a ticket with an id “CELLSNET-42328” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Example Test:
A template file contains markers i.e. &=Parent.Name and &=Parent.Child.Name into A1 and B1 cells in the worksheet.
e.g
Sample code:

// ****** Program ******
//Initialize WorkbookDesigner object
WorkbookDesigner designer = new WorkbookDesigner();
//Load the template file
designer.Workbook = new Workbook(“e:\test2\SM_NestedBook1.xlsx”);
//Instantiate the List based on the class
System.Collections.Generic.ICollection list = new System.Collections.Generic.List();
//Create an object for the Parent class
Parent p1 = new Parent(“Parent1”);
//Create the relevant child class for the Parent
p1.Child = new Child(“Child1Parent1”);
p1.Child = new Child(“Child2Parent1”);

//Create another object for the Parent class
Parent p2 = new Parent(“Parent2”);
//Create the relevant child class for the Parent
p2.Child = new Child(“Child1Parent2”);
p2.Child = new Child(“Child2Parent2”);
//Add the objects to the list
list.Add(p1);
list.Add(p2);
//Specify the DataSource
designer.SetDataSource(“Parent”, list);
//Process the markers
designer.Process(false);
//Save the Excel file.
designer.Workbook.Save(“e:\test2\out_SM_NestedBook2.xlsx”);

class Parent
{

private String m_Name;

public String Name
{
get { return m_Name; }
set { m_Name = value; }
}
internal Parent(string name)
{
this.Name = name;
}
private Child m_child;

public Child Child
{
get { return m_child; }
set { m_child = value; }
}

}
public class Child
{
public Child(string name)
{
this.m_name = name;
}

private string m_name;

public string Name
{
get { return m_name; }
set { m_name = value; }
}

In the output file, both parent objects have only one child objects.


And, regarding your requirement about Parent object on top and child objects under it, I think you are demanding something like hierarchical structure or tree nodes, I am afraid, such a format is not supported in Smart Markers feature, so you would always have to do it by yourself. For example, you may group rows to group data accordingly once the data is filled or sorted out, see the topic for reference:

Thank you.

Ok, Thanks for the quick response.

Hi,


This is to inform you that we have fixed your issue “CELLSNET-42328” now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Thank you.