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

Free Support Forum - aspose.com

SmartMarkers with relational data?

I am trying to output relational data in a spreadsheet by using smartmarkers.

// Sample Objects:
public class Parent
{
public long ParentId {get; set;}
public string Name {get; set;}
public IList Children {get; set;}
}
public class Child
{
public long ChildId {get; set;}
public string Name {get; set;}
}

// Sample Code:
IList parent = new List()
{
new Parent()
{
ParentId = 1,
Name = “George”,
Children = new List()
{
new Child() { ChildId = 1, Name = “Jimmy” },
new Child() { ChildId = 2, Name = “Susan” }
}
},
new Parent()
{
ParentId = 2,
Name = “Samantha”,
Children = new List()
{
new Child() { ChildId = 3, Name = “Jake” },
new Child() { ChildId = 4, Name = “Isaac” },
new Child() { ChildId = 5, Name = “Luke” }
}
}
};

WorkbookDesigner wd = new WorkbookDesigner();
wd.SetDataSource(“parent”, parent);
wd.Process();

// Sample SmartMarkers in Excel File:
…and then render that by applying SmartMarkers in a spreadsheet:

A B C D E
1
Parent
Children
Age

2 &=parent.Name(noadd,skip:1)
&=parent.Age

3
&=parent.Children.Name &=parent.Children.Age

4




I've tried a couple variants of this, including group:normal, etc. but nothing seems to work the way I want it. What I would like it to look like is this:
A B C D E
1
Parent
Children
Age

2
George

34

3
Jimmy 3

4
Susan
1

5




6
Samantha

45

7

Jake
20

8

Isaac
18

9

Luke
7



Thanks for any advice!
/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

<![endif]–>

Hi,

Thank you for considering Aspose.

We do not support your required feature. You may check the following code and see if it fits your need:

public class Person

{

public long Id { get; set; }

public string Name { get; set; }

public int Age { get; set; }

public long ChildId { get; set; }

public string ChildName { get; set; }

}

class Program

{

static void Main(string[] args)

{

IList<Person> person = new List<Person>()

{

new Person()

{

Id = 1,

Name = "George",

ChildName = null,

Age = 100,

},

new Person()

{

Id = 1,

Name = "George",

ChildId = 1,

ChildName = "Jimmy",

Age = 50,

},

new Person()

{

Id = 1,

Name = "George",

ChildId = 2,

ChildName = "Susan",

Age = 50,

},

new Person()

{

Id = 2,

Name = "Samantha",

ChildName = null,

Age = 80,

},

new Person()

{

Id = 2,

Name = "Samantha",

ChildId = 3,

ChildName = "Jake",

Age = 50,

},

new Person()

{

Id = 2,

Name = "Samantha",

ChildId = 4,

ChildName = "Isaac",

Age = 50,

},

};

WorkbookDesigner wd = new WorkbookDesigner();

wd.Open(@"F:\FileTemp\book2.xls");

wd.SetDataSource("Person", person);

wd.Process();

wd.Save(@"F:\FileTemp\dest.xls");

}

}

The data in the book2.xls as :
Parent

Children Age

&=Person.Name(group:normal,skip:1) &=Person.ChildName &=Person.Age<o:p></o:p>

Thank You & Best Regards,

Is there any way to group data over more than one row? Could I do this by using SmartMarkers with 2 different data sources (one for parent data and one for child data)? If not, what is the suggested way to do what I need?

Hi,

Thank you for considering Aspose.

Please provide us some further details about your requirement. Please create a template file manually in MS Excel to explain your requirement and post it here. We will check it and get back to you soon.

Thank You & Best Regards,