- Demo
- C# source
- VB.Net source
The sample demonstrates how to load excel 2007 format file.
private void btnRun_Click(object sender, System.EventArgs e) { Workbook workbook = new Workbook(); workbook.LoadFromFile(@"..\..\..\..\..\..\Data\MarkerDesignerSample.xlsx", ExcelVersion.Version2007); 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.xlsx"); 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 New Workbook() workbook.LoadFromFile("..\..\..\..\..\..\Data\MarkerDesignerSample.xlsx",ExcelVersion.Version2007) 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.xlsx") ExcelDocViewer(workbook.FileName) End Sub Private Sub ExcelDocViewer(ByVal fileName As String) Try System.Diagnostics.Process.Start(fileName) Catch End Try End Sub