The sample demonstrates how to use WorkbookDesigner.
private void btnRun_Click(object sender, System.EventArgs e) { Workbook workbook = new Workbook(); workbook.LoadFromFile(@"..\..\..\..\..\..\Data\MarkerDesignerSample.xls"); DataTable dt = (DataTable)dataGrid1.DataSource; Worksheet sheet = workbook.Worksheets[0]; workbook.MarkerDesigner.AddParameter("Variable1",1234.5678); workbook.MarkerDesigner.AddDataTable("Country",dt); workbook.MarkerDesigner.Apply(); sheet.AllocatedRange.AutoFitRows(); sheet.AllocatedRange.AutoFitColumns();; workbook.SaveToFile("Sample.xls"); ExcelDocViewer(workbook.FileName); } private void ExcelDocViewer( string fileName ) { try { System.Diagnostics.Process.Start(fileName); } catch{} }
Private Sub btnRun_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRun.Click Dim workbook As Workbook = New Workbook() workbook.LoadFromFile("..\..\..\..\..\..\Data\MarkerDesignerSample.xls") Dim dt As DataTable = CType(dataGrid1.DataSource, DataTable) Dim sheet As Worksheet = workbook.Worksheets(0) workbook.MarkerDesigner.AddParameter("Variable1",1234.5678) workbook.MarkerDesigner.AddDataTable("Country",dt) workbook.MarkerDesigner.Apply() sheet.AllocatedRange.AutoFitRows() sheet.AllocatedRange.AutoFitColumns() workbook.SaveToFile("Sample.xls") ExcelDocViewer(workbook.FileName) End Sub Private Sub ExcelDocViewer(ByVal fileName As String) Try System.Diagnostics.Process.Start(fileName) Catch End Try End Sub