Hey Aspose-Team/Community,
I’ve tried to load data from a SQL-Table and put it into an excel-sheet. As far as good, but now I wanted to define a layout for the generated excel-file. I’ve created a template and saved it on my pc. For the next step I loaded the data to a DataTable and want to publish the data to the Workbook but there is no Data transmitted. I found an example of you which were quite similar to my needs but you have to create a custom class which represents the Data I want to fetch and since my application should be dynamic I can’t create custom classes (although with that class it were successfull).
The Code-Snippet:
// Instantiating a WorkbookDesigner object
WorkbookDesigner designer = new WorkbookDesigner();
// Open a designer spreadsheet containing smart markers
designer.Workbook = wb;
DataTable tab = new DataTable();
// Create DataAdapter
SqlDataAdapter da = new SqlDataAdapter(cmd);
// query the result of the SQL to the DataTable
da.Fill(tab);
// Set the DataSource for the Designer spreadsheet
designer.SetDataSource(“ExcelTest”, tab);
// Process the smart markers
designer.Process();
The result of the SQL-Query is not empty and of course I do save the file afterwards.