We’ve created and updating regularly our sample code library so you may quickly learn swap cells and their values and the step-by-step process in VB.NET. ByteScout Spreadsheet SDK was made to help with swap cells and their values in VB.NET. ByteScout Spreadsheet SDK is the library (SDK) that is capable of writing, reading, modifying and calculating Excel and CSV spreadsheets. Most popular formulas can be calculated and reculculated with Excel installed. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays.
VB.NET code snippet like this for ByteScout Spreadsheet SDK works best when you need to quickly implement swap cells and their values in your VB.NET application. In order to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. Enjoy writing a code with ready-to-use sample VB.NET codes to implement swap cells and their values using ByteScout Spreadsheet SDK.
Trial version can be obtained from our website for free. It includes this and other source code samples for VB.NET.
Imports System Imports System.Collections.Generic Imports System.Text Imports Bytescout.Spreadsheet Imports System.Diagnostics Imports System.IO Module Module1 Sub Main() ' Open existing Spreadsheets Dim document1 As New Spreadsheet() document1.LoadFromFile("input.xls") ' Get first cell value Dim value1 As Object = document1.Worksheet(0).Cell("A1").Value ' Get another cell value Dim value2 As Object = document1.Worksheet(0).Cell("B1").Value ' Swap them Dim value3 As Object value3 = value2 value2 = value1 value1 = value3 document1.Worksheet(0).Cell("A1").Value = value1 document1.Worksheet(0).Cell("B1").Value = value2 ' remove output file if already exists If File.Exists("Output.xls") Then File.Delete("Output.xls") End If ' Save document document1.SaveAs("Output.xls") ' Close Spreadsheet document1.Close() ' open in default spreadsheets viewer/editor Process.Start("Output.xls") End Sub End Module