Import to workbook(excel) from list of custom objects

How can I import a list of custom objects into a workbook in aspose cells java.
For example I have a object as follows
class Test{

String name;
String value;

}
and I have a list of such objects I need to import this list into workbook.

@virinchi,

See the following sample code for your reference:
Person.java

public class Person

{

      String name;

      int age;

      int salary;



      public Person(String name, int age, int salary)

      {

            this.name = name;

            this.age = age;

            this.salary = salary;

      }


      public String getName()

      {

            return this.name;

      }


      public void setName(String value)

      {

            this.name = value;

      }


      public int getAge()

      {

            return this.age;

      }


      public void setAge(int value)

      {

            this.age = value;

      }


      public int getSalary()

      {

            return this.salary;

      }


      public void setSalary(int value)

      {

            this.salary = value;

      }

}

Main.Java

Workbook workbook = new Workbook();


Worksheet worksheet = workbook.getWorksheets().get(0);


ArrayList<Person> p = new ArrayList<Person>();


p.add(new Person("Bob", 10, 500));

p.add(new Person("John", 20, 520));

p.add(new Person("Jack", 30, 550));

p.add(new Person("James", 10, 520));

p.add(new Person("Joe", 30, 560));

p.add(new Person("Jarry", 40, 570));


//worksheet.getCells().importCustomObjects(p, null, true, 1, 1, -1, true, "", false);


//Simpler method to use.

worksheet.getCells().importCustomObjects(p, 1, 1, null);


workbook.save("F:\\Shak-Data-RW\\Downloads\\output.xlsx");

Hope, this helps a bit.

Hi
Thanks this helps.

@virinchi,

You are welcome.