Every ByteScout tool includes simple example VB.NET source codes that you can get here or in the folder with installed ByteScout product. ByteScout Data Extraction Suite can convert template to xls with spreadsheet sdk. It can be applied from VB.NET. ByteScout Data Extraction Suite is the set that includes 3 SDK products for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK.
The SDK samples given below describe how to quickly make your application do convert template to xls with spreadsheet sdk in VB.NET with the help of ByteScout Data Extraction Suite. Follow the instructions from scratch to work and copy the VB.NET code. Applying VB.NET application mostly includes various stages of the software development so even if the functionality works please test it with your data and the production environment.
If you want to try other source code samples then the free trial version of ByteScout Data Extraction Suite is available for download from our website. Just try other source code samples for VB.NET.
Imports System.Diagnostics Imports System.IO Imports Bytescout.Spreadsheet Class Program Friend Shared Sub Main(args As String()) ' Open spreadsheet from file Dim document As New Spreadsheet() document.LoadFromFile("template.xls") ' Get first worksheet Dim worksheet As Worksheet = document.Workbook.Worksheets(0) ' Find macros and replace them with values Replace(worksheet, "<PRODUCT_NAME1>", "Product 1", Nothing) Replace(worksheet, "<PRODUCT_NAME2>", "Product 2", Nothing) Replace(worksheet, "<PRICE1>", 24.99F, "0.00") Replace(worksheet, "<PRICE2>", 29.99F, "0.00") Replace(worksheet, "<QANTITY1>", 5, Nothing) Replace(worksheet, "<QANTITY2>", 10, Nothing) ' Delete output file if exists If File.Exists("output.xls") Then File.Delete("output.xls") End If ' Save document document.SaveAs("output.xls") ' Close spreadsheet document.Close() ' Open generated XLS document in default application Process.Start("output.xls") End Sub Private Shared Sub Replace(worksheet As Worksheet, macro As String, value As Object, format As String) Dim cell As Cell = worksheet.Find(macro, True, False, False) While cell IsNot Nothing cell.Value = value If Not [String].IsNullOrEmpty(format) Then cell.NumberFormatString = format End If cell = worksheet.FindNext() End While End Sub End Class