Free Support Forum - aspose.com

Necessary to use WorkbookDesigner class when using Smart Markers

Hi,

I wanted to know that is it necessary
to use WorkBookDesigner Class while using smartMarkers?
As it is mentioned in the code

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/smart-markers.html
under Using Anonymous Types or Custom Objects.
//Definition of Custom class.

public class MyProduct


{


private string m_Name;



public string Name


{


get { return m_Name; }


set { m_Name = value; }


}


private int m_Age;



public int Age


{


get { return m_Age; }


set { m_Age = value; }


}


internal MyProduct(string name, int age)


{


this.m_Name = name;


this.m_Age = age;


}



}




// ****** Program ******



//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.


w.Cells[“A1”].PutValue(“Test”);


w.Cells[“A2”].PutValue("&=MyProduct.Name");


w.Cells[“B2”].PutValue("&=MyProduct.Age");



//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.


report.Process(false);



//Save the excel file.


report.Workbook.Save(“f:\test\out_customobjects.xls”);



Can we also use Workbook class to process SmartMarker in excel sheet?



Hi,

Yes, it is necessary to use WorkbookDesigner class. Actually WorkbookDesigner.Process method process all the smart markers inside the workbook.

Hi,


Yes, to process Smart Markers you have to use WorkbookDesigner class/object.
If you need to process smart markers in a specific sheet, you may use the overloaded version i.e.
WorkbookDesigner.Process (int sheetIndex, bool isPreserved) --> give 0, 1.2 etc. for your specific sheet index for the parameter.

Thank you.

Thanks Amjad.

Thanks Faiz