Free Support Forum - aspose.com

Smart Marker - Many files

Hi,

We use Smart Markers to generate an excel page which is great.

Is there a way to use Smart Markers but to create it for multiple times?

That is, we can generate 5 files of the same template with multiple data?

Thanks!

Hi,

I think you may utilize looping mechanism to open your template file, process markers based on your datasource and save as multiple copies of the workbook(s).

E.g.,

OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=d:\\test\\Northwind.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("Select * from Products",con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;

DataSet ds = new DataSet();
da.Fill(ds,"Products");
DataTable dt = ds.Tables["Products"];
WorkbookDesigner wd;

for(int i = 1; i<=5;i++)
{
wd = new WorkbookDesigner();
wd.Open("d:\\test\\sourcetemplate.xls");
wd.SetDataSource(dt);
wd.Process();
wd.Save("d:\\test\\outputbook" + i.ToString() + ".xls");
}
Thank you.