- Demo
- C# source
- VB.Net source
The sample demonstrates how to copy cell data in Excel workbook via Spire.XLS.
using Spire.Xls; namespace CopyCellData { class Program { static void Main(string[] args) { Workbook workbook = new Workbook(); workbook.LoadFromFile(@"..\..\..\..\Data\parts.xls",ExcelVersion.Version97to2003); Worksheet worksheet = workbook.Worksheets[0]; //copy the A3-E5 to A19-E21 worksheet.Copy(worksheet.Range["A3:E5"],worksheet.Range["A19:E21"],true); workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003); System.Diagnostics.Process.Start(workbook.FileName); } } }
Imports Spire.Xls Namespace CopyCellData Friend Class Program Shared Sub Main(ByVal args() As String) Dim workbook As New Workbook() workbook.LoadFromFile("..\..\..\..\Data\parts.xls",ExcelVersion.Version97to2003) Dim worksheet As Worksheet = workbook.Worksheets(0) 'copy the A3-E5 to A19-E21 worksheet.Copy(worksheet.Range("A3:E5"),worksheet.Range("A19:E21"),True) workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003) System.Diagnostics.Process.Start(workbook.FileName) End Sub End Class End Namespace