Free Support Forum - aspose.com

Combining Smart Markers and direct manipulation of worksheets

Could you please tell me what would be the best approach in case I decide to use Smart Markers and directly manipulate worksheets.

i.e. can I do :
1) designer.open()
2) add some smart marker variables on the fly
3) designer.execute()
4) add another worksheet by using designer.excel.worksheet[X].Cells.ImportDataTable()

or is there a better way to do this?


Your approach can work without any problem. Just some small mistakes:
1) designer.open()
2) add some smart marker variables on the fly
3) designer.execute() – We provide Process method instead of Execute method
4) add another worksheet by using designer.excel.worksheet[X].Cells.ImportDataTable() – Workshseet.Add method is used to add another worksheet. Cells.ImportDataTable method is used to import data from a DataTable. We also provide many other APIs to manipulate data. Please check our API reference. They are mainly included in Cells and Cell class.




It’s better to add smart makers at designer file for Aspose.Excel already provides APIs to manipulate worksheets easily. However, if you find that some smart maker variables should be set at run time, your approach is best.

Thanks!

few more questions.

There are two possible scenarious, one involves smart markers and one does not. Can I use designer.Excel directly without using designer.Open, designer.SetDataSource and designer.Process()?

i.e.

ExcelDesigner designer = new Designer();

scenario 1:
designer.open()
designer.SetDataSource()
designer.process();
designer.excel.save()

scenario 2
designer.excel.open() // or designer.excel = new Excel()
designer.excel.worksheet[0].Cells.Import …
designer.excel.save();


I also have a suggestion for adding a method to Excel class;
OpenFileViaStream(string designerFile)
{

FileStream fileStream = new FileStream(designerFile, FileMode.Open, FileAccess.Read);

byte[] data1 = new byte[fileStream.Length];

fileStream.Read(data1, 0, data1.Length);

fileStream.Close();

MemoryStream memoryStream = new MemoryStream(data1);

this.Open(memoryStream);

}

This method would be used for web apps, since opening the file directly is not an option.

If you don’t use smart markers in you application, you don’t have to use ExcelDesigner class, just use Excel class.

Could you elaborate your method? We already provide options to open file directly or from memory stream. Please check http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.ExcelDesigner.Open.html and http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.Excel.Open.html.

So why adding your method to Excel class? Thank you for clarification.