Using Anonymous Types or Custom Objects

Aspose.Cells also supports anonymous types or custom objects in smart markers. In below example Product class is need to be defined before use.

 string FilePath = @"..\..\..\Sample Files\";

string FileName = FilePath + "Using Custom Objects.xlsx";

//Instantiate the workbookdesigner object.

WorkbookDesigner report = new WorkbookDesigner();

//Get the first worksheet(default sheet) in the workbook.

Aspose.Cells.Worksheet w = report.Workbook.Worksheets[0];

//Input some markers to the cells.




//Instantiate the list collection based on the custom class.

IList<MyProduct> list = new List<MyProduct>();

//Provide values for the markers using the custom class object.

list.Add(new MyProduct("Simon", 30));

list.Add(new MyProduct("Johnson", 33));

//Set the data source.

report.SetDataSource("MyProduct", list);

//Process the markers.


//Save the excel file.




Download Sample Code