ByteScout Barcode Suite - C# - Convert template to xls with spreadsheet sdk - ByteScout

ByteScout Barcode Suite – C# – Convert template to xls with spreadsheet sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Suite – C# – Convert template to xls with spreadsheet sdk

How to convert template to xls with spreadsheet sdk in C# using ByteScout Barcode Suite

If you want to learn more then this tutorial will show how to convert template to xls with spreadsheet sdk in C#

Source code documentation samples give simple and easy method to install a needed feature into your application. Want to convert template to xls with spreadsheet sdk in your C# app? ByteScout Barcode Suite is designed for it. ByteScout Barcode Suite is the set that includes three different SDK products to generate barcodes, read barcodes and read and write spreadsheets: Barcode SDK, Barcode Reader SDK and Spreadsheet SDK.

Want to save time? You will save a lot of time on writing and testing code as you may just take the C# code from ByteScout Barcode Suite for convert template to xls with spreadsheet sdk below and use it in your application. Simply copy and paste in your C# project or application you and then run your app! Use of ByteScout Barcode Suite in C# is also described in the documentation included along with the product.

ByteScout provides the free trial version of ByteScout Barcode Suite along with the documentation and source code samples.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.Diagnostics; using System.IO; using Bytescout.Spreadsheet; namespace TemplateToXls { class Program { static void Main(string[] args) { // Open spreadsheet from file Spreadsheet document = new Spreadsheet(); document.LoadFromFile("template.xls"); // Get first worksheet Worksheet worksheet = document.Workbook.Worksheets[0]; // Find macros and replace them with values Replace(worksheet, "<PRODUCT_NAME1>", "Product 1", null); Replace(worksheet, "<PRODUCT_NAME2>", "Product 2", null); Replace(worksheet, "<PRICE1>", 24.99f, "0.00"); Replace(worksheet, "<PRICE2>", 29.99f, "0.00"); Replace(worksheet, "<QANTITY1>", 5, null); Replace(worksheet, "<QANTITY2>", 10, null); // Delete output file if exists if (File.Exists("output.xls")) { File.Delete("output.xls"); } // Save document document.SaveAs("output.xls"); // Close spreadsheet document.Close(); // Open generated XLS document in default application Process.Start("output.xls"); } static void Replace(Worksheet worksheet, string macro, object value, string format) { Cell cell = worksheet.Find(macro, true, false, false); while (cell != null) { cell.Value = value; if (!String.IsNullOrEmpty(format)) { cell.NumberFormatString = format; } cell = worksheet.FindNext(); } } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next