With this source code sample you may quickly learn how to set cell formula in VB.NET. ByteScout Spreadsheet SDK: the SDK component for writing, reading, modifying and calculating Excel and CSV spreadsheets. Can calculate and reculculate formulas with Excel installed. You may import or export data to and from CSV, XML, JSON. Supports export to databases, arrays, streams. It can set cell formula in VB.NET.
VB.NET code samples for VB.NET developers help to speed up coding of your application when using ByteScout Spreadsheet SDK. Follow the instructions from the scratch to work and copy the VB.NET code. This basic programming language sample code for VB.NET will do the whole work for you to set cell formula.
ByteScout Spreadsheet SDK free trial version is available on our website. VB.NET and other programming languages are supported.
Imports Bytescout.Spreadsheet Imports System.IO Module Module1 Sub Main() ' Create new Spreadsheet Dim document As New Spreadsheet() ' add new worksheet Dim Sheet As Worksheet = document.Workbook.Worksheets.Add("FormulaDemo") ' headers to indicate purpose of the column Sheet.Cell("A1").Value = "Formula (as text)" ' set A column width Sheet.Columns(0).Width = 250 Sheet.Cell("B1").Value = "Formula (calculated)" ' set B column width Sheet.Columns(1).Width = 250 ' write formula as text Sheet.Cell("A2").Value = "7*3+2" ' write formula as formula Sheet.Cell("B2").Value = "=7*3+2" ' remove output file if already exists If File.Exists("Output.xls") Then File.Delete("Output.xls") End If ' Save document document.SaveAs("Output.xls") ' Close Spreadsheet document.Close() ' open in default spreadsheets viewer/editor Process.Start("Output.xls") End Sub End Module