Free Support Forum - aspose.com

Export a master detail grid

Hello,

Is it possible to export a master detail grid to excel with Aspose.cell?
In my dataset , I have two table , one for the master and one for the detail.

Thanks
Arnold

Hi Arnold,

You can use you own code to populate data in your dataset into Excel file with Aspose.Cells. Aspose.Cells is flexible enough to allow you to do that.

I have added a relation for my dataset, but I do not know how to build the excel template.
For example, this is What I have in my excel template::
&=masterTable.categoryproduct
&=childTable.nameproduct | &=childTable.productprice | &=childTable.color

But the result shows first the list of all categoryproduct(parentTable) and then the list of all childTable.

Thanks for your assistance

Smart marker feature doesn't support this master-child relationship.

You can populate child table data first then insert the master table at the appropriate position.

I am sorry but I really do not get it.
How should I populate the excel spreadsheet?

I fill my dataset this way:
sqlDA_productcategory.Fill(dS_pfmea1,ParentTable);
sqlDA_product.Fill(dS_pfmea1,ChildTable);

if(dS_pfmea1.Relations.Count<1)

dS_pfmea1.Relations.Add(dS_pfmea1.Tables[ParentTable].Columns[RelationColumn],dS_pfmea1.Tables[ChildTable].Columns["etridcategory"]);

Then this is how I populate the spreadsheet:

this.dataTable1 = new DataTable();

Excel excel = new Excel();

string path = MapPath(".");

string designerFile = path + "\\test.xls";

excel.Open(designerFile);

this.dataTable1.Reset();

this.sqlDA_productcategory.Fill(this.dataTable1);

this.sqlDA_product.Fill(this.dataTable1);

Worksheet sheet = excel.Worksheets[0];

sheet.Cells.ImportDataTable(this.dataTable1, false, 6, 1);

sheet.Name = "Products List";

while(excel.Worksheets.Count > 1)

excel.Worksheets.RemoveAt(excel.Worksheets.Count - 1);

excel.Save("AlphabeticalList.xls", SaveType.OpenInBrowser, FileFormatType.Default, this.Response);

The result I get is: the list of all the parent and then the list of all the child
FRUIT
MEAT
FISH
orange
banana
chiken
Turkey
Salmon

I would like the following:
FRUIT
banana $10 5lb
orange $ 6 2lb

MEAT
chicken $20 10lb
turkey $30 5lb

FISH
Slamon $50 $15

What method should I then use to populate the escel spreadsheet?
Thanks

I think there isn't a simple approach to serve your need.

You have to loop through your datatables and use PutValue method to populate data cell by cell according to the relationship in your data tables.

I will consider if we can enhance smart marker feature to serve your need. However, I think it's complex and I don't have ideas on a direct solution.

Hello

Has this functionality been added for the smart marker?

Thanks for your help

Sorry, this feature is not added yet.

Hello

Just checking if this funcitonality has been added yet

Thanks

We are still working on this feature.

We will add it to Aspose.Cells for Reporting Services first then port it to Aspose.Cells for .Net.