How to use nested objects in java

Hi,


I am calling one class in another class. Here BasicDetails is my class which contains DerivedDetails class object.


BasicDetails.java

public class BasicDetails {
private String accountID;
private String accountName;
public DerivedDetails derivedDetails;
public DerivedDetails getDerivedDetails() {
return derivedDetails;
}
public void setDerivedDetails(DerivedDetails derivedDetails) {
this.derivedDetails = derivedDetails;
}
public String getAccountID() {
return accountID;
}
public BasicDetails(String accountID, String accountName , DerivedDetails derivedDetails) {
super();
this.accountID = accountID;
this.accountName = accountName;
this.derivedDetails = derivedDetails;
}
public BasicDetails() {
}
public void setAccountID(String accountID) {
this.accountID = accountID;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}

DerivedDetails.java
package com.moodys.samples;

public class DerivedDetails {
private String sign;
private String accountDescription;
private String coa;
private int accountID;
private String derivedAccount;
public DerivedDetails() {
// TODO Auto-generated constructor stub
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}

public String getAccountDescription() {
return accountDescription;
}
public void setAccountDescription(String accountDescription) {
this.accountDescription = accountDescription;
}
public String getCoa() {
return coa;
}
public void setCoa(String coa) {
this.coa = coa;
}
public int getAccountID() {
return accountID;
}
public void setAccountID(int accountID) {
this.accountID = accountID;
}
public String getDerivedAccount() {
return derivedAccount;
}
public void setDerivedAccount(String derivedAccount) {
this.derivedAccount = derivedAccount;
}

}


WorkbookDesigner designer = new WorkbookDesigner();
designer.setWorkbook(workbook);
//get worksheet Cells collection
Cells cells = designer.getWorkbook().getWorksheets().get(“Example Ratio”).getCells();

//Create Array list
ArrayList list = new ArrayList();
BasicDetails bs = new BasicDetails();
DerivedDetails ds = new DerivedDetails();
ds.setAccountDescription(“LoanLoss”);
ds.setSign("+");
ds.setAccountID(6065);
ds.setDerivedAccount(“yes”);
ds.setCoa(“DerivedAccount”);
// bs.DerivedDetails = new DerivedDetails( “77”,“Loan Loss”,“DerivedAccount”,6065,“yes”);
bs.setDerivedDetails(ds);
bs.setAccountID(“500010”);
bs.setAccountName(“BOA”);
list.add(bs);
designer.setDataSource(“BasicDetails”, list);
try{
designer.process(false);
}catch(Exception e){
e.printStackTrace();
}
try{
workbook.save(“C:\Users\ExcelCharts\”+getFileName()+".xls");
}catch(Exception e){
e.printStackTrace();
}
}

But i am not getting the values which are present in the Derived class, we are directly getting an object in place of the value in the output excel. Please help me.

Hi Padma,

Thanks for using Aspose.Cells.

It seems, simple nested one level objects are not supported in Aspose.Cells for Java, or there is a bug which needs to be fixed. We found that Aspose.Cells are not printing the values of the nested object instead it is printing the objects memory ids.

Please see the screenshot of the designer and output file generated via smart markers. I have also attached the sample code files used to generate the output file for a reference.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40864.

Hi,

Any fix done for this issue??

Regards,
Praveen

Hi Praveen,

Thanks for your posting and using Aspose.Cells.

We are afraid, there is not any update for you at this moment. However, we have logged your comment in our database against this issue and requested the development team to provide some fix or ETA for this issue. Once, there is some news for you, we will let you know asap.

Hi,

Thanks for using Aspose.Cells.

Please download and use the latest version: Aspose.Cells for Java 8.6.2 it supports the nested object in java.

Here is the output of the sample code given in the above post. I have also attached the screenshot of the output excel file for a reference.

Also we have updated the Smart Markers article. Please check the section

Using Nested Objects

( Smart Markers|Documentation )

The issues you have found earlier (filed as CELLSJAVA-40864) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.