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

Free Support Forum - aspose.com

Recursive Data in Workbookdesigner

Hi,
I have some recursive data in a DataSet which I would put into WorkbookDesigner. The recursion is mapped using DataSet.Relations - List with id->parentId relation.
Do I have any chance to display that recursive data with cells?
So, my aims are:

  • Getting parent-elements above children-elements
  • Indent elements based on their depth in the structure
  • Set background-colors of node elements

Is this possible, anyhow?
Cheers, Torsten.

Hi,

Thanks for your inquiry.

Could you create sample excel file(s) manually in MS Excel to explain what are your requirements, we will check the feasibility and may update you soon.

Also, kindly check the following document for your reference, it explain how one can utilize smart markers feature in different scenarios.

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/smart-markers.html

Thank you.

Thanks for your response!
I already tried/use the smart markers and I really love them. …until I stucked today. :wink:
So, here we go.
I want a document like the attached aim.xls.
This is the export of a project management tool.
Here is the rough data structure:
-Project
----Milestone
--------Workpackage
--------Workpackage
--------------Milestone
----------------------Workpackage
----------------------Workpackage


----Milestone
---------Workpackage
----Workpackage



Workpackages have planned hours, written hours, costs,…
These hours/costs are accumulated for the milestones.

Here is my first draft for the template, see template.xls. (Input is a dataset)
And here is the output, see Result_UsingWorkpackageDesigner.xls.



Thanks for your help. :slight_smile:

Hi,

Thanks for providing us template files and further details.

We will look into it and get back to you soon.

Thank you.

Hi,

Well, I 'm afraid we cannot simply support this feature in smart markers. You have to set all your data by yourself.

See the following example codes:

internal bool ProcessDataTable(Cells cells,ref int rowIndex, DataTable dt, int parentId,int level)

{

DataRow[] rows = dt.Select("ParentId = "+ parentId);

if (rows == null || rows.Length == 0)

{

return false;

}

for (int i = 0; i < rows.Length; i++)

{

DataRow row = rows[i];

for (int j = 0; j < dt.Columns.Count; j++)

{

cells[rowIndex, j].PutValue(row[j]);

if (j == 2)//string text

{

Style style = cells[rowIndex, 2].GetStyle();

style.HorizontalAlignment = TextAlignmentType.Left;

style.IndentLevel = level;

cells[rowIndex, 2].SetStyle(style);

}

}

int currentIndex = rowIndex++;

bool hasChildren = this.ProcessDataTable(cells, ref rowIndex, dt,

(int)row["Id"], level + 1);

if (hasChildren)

{

//set cell back ground



}

}

return true;


}

Workbook workbook = new Workbook();

DataTable dt = new DataTable("Table2");

dt.Columns.Add("Id", typeof(int));

dt.Columns.Add("ParentId", typeof(int));

dt.Columns.Add("Text");

dt.Rows.Add(new object[] { 1,9,"Lastenheft"});

dt.Rows.Add(new object[] { 2,9,"Pflichtenheft"});

dt.Rows.Add(new object[] { 3,9,"Test"});

dt.Rows.Add(new object[] { 4,9,"Spezifikation"});

dt.Rows.Add(new object[] { 5,10,"Datenbank Design"});

dt.Rows.Add(new object[] { 6,10,"SW-Paket Administration, Benutzerverwaltung"});

dt.Rows.Add(new object[] { 7,10,"Prozessabwicklung"});

dt.Rows.Add(new object[] { 8,10,"AP3"});

dt.Rows.Add(new object[] { 9,-1,"Meilenstein 1"});

dt.Rows.Add(new object[] { 10, -1, "Meilenstein 2" });

dt.Rows.Add(new object[] { 11, -1, "Meilenstein 3" });

dt.Rows.Add(new object[] { 12,11,"AP M3.1"});

dt.Rows.Add(new object[] { 13,11,"AP2"});

dt.Rows.Add(new object[] { 14, -1, "MS4"});

dt.Rows.Add(new object[] { 15,14,"MS4.1"});

dt.Rows.Add(new object[] { 16,15,"aaa"});

int rowIndex = 0;

this.ProcessDataTable(workbook.Worksheets[0].Cells, ref rowIndex, dt, -1, 0);

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

Thank you.

Yeah, thanks, that works.
OK, its not as beautiful as with smart markers but it works. Maybe you can put that recursive thing on your roadmap. :wink:

Thanks for your quick help!