ByteScout Spreadsheet SDK - C# - Convert Template To XLS - ByteScout

ByteScout Spreadsheet SDK – C# – Convert Template To XLS

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Convert Template To XLS

How to convert template to XLS in C# using ByteScout Spreadsheet SDK

This code in C# shows how to convert template to XLS with this how to tutorial

The code below will help you to implement an C# app to convert template to XLS. Want to convert template to XLS in your C# app? ByteScout Spreadsheet SDK is designed for it. ByteScout Spreadsheet SDK is the SDK that can write and read, modify and calculate Excel and CSV spreadsheets. Most popular formulas are supported. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays.

C# code samples for C# developers help to speed up coding of your application when using ByteScout Spreadsheet SDK. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Use of ByteScout Spreadsheet SDK in C# is also explained in the documentation included along with the product.

Free trial version of ByteScout Spreadsheet SDK is available on our website. Documentation and source code samples are included.

Try ByteScout Spreadsheet SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

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(); } } } }

Try ByteScout Spreadsheet SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)



Get 60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Get ByteScout Spreadsheet SDK Free Training


Get Your Free API Key

Explore Web API Documentation