Designer template with variable number of worksheets

I am considering purchasing Aspose.Excel, but have two questions:

1) Does Aspose.Excel have a tool that would load in an Excel spreadsheet and return the VB or C# code that could be used to generate that spreadsheet from scratch? This would be useful for those of us who have premade spreadsheets but don’t want to use the Designer feature.

2) Is it possible to use the Designer feature to create a spreadsheet with a variable number of worksheets that are created at run-time? For example, let’s say I have a Designer worksheet that is a budget template for a project. But I want to be able to generate a spreadsheet that contains one budget worksheet for each project that is currently active. Can I use the Designer functionality to generate multiple worksheets from that one template, and put them all into one spreadsheet?

  1. No, we don’t have such a tool.
  2. I don’t clearly understand your question. Do you mean you have a template with a budget worksheet and you want to make several copys of that sheet at run time? If yes, you can do it. Please check Workbook.Copy method and Copying and Moving Worksheets articles for your reference.

Let’s say that I have a Designer spreadsheet, titled “Designer.xls”. Designer.xls contains one worksheet, titled “Template.”

I would like to create a new spreadsheet, called “New.xls” that will contain three worksheets, “Sheet1”, “Sheet2”, and “Sheet3”. Each worksheet will use Template, but the data to be put into the smart markers will be different for each of those worksheets. So, Sheet1 will populate the smart markers with datasource1, Sheet2 will populate the smart markers with datasource2, and Sheet3 will populate the smart markers with datasource3.

Can this be easily done?

Yes, you can. Smart markers can work on worksheet level.

Following is a simple sample:

//Populate smart markers with datasource1
excelDesigner.SetDataSource(datasource1);
excelDesigner.Process(0, true);
excelDesigner.ClearDataSource();

//Populate smart markers with datasource2
excelDesigner.SetDataSource(datasource2);
excelDesigner.Process(1, true);
excelDesigner.ClearDataSource();

//Populate smart markers with datasource3
excelDesigner.SetDataSource(datasource3);
excelDesigner.Process(2, true);
excelDesigner.ClearDataSource();