ByteScout Data Extraction Suite - C# - Convert template to xls with spreadsheet sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

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

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

How to convert template to xls with spreadsheet sdk in C# and ByteScout Data Extraction Suite

Learn to code in C# to convert template to xls with spreadsheet sdk with this step-by-step tutorial

An easy to understand sample source code to learn how to convert template to xls with spreadsheet sdk in C# ByteScout Data Extraction Suite is the bundle that includes three SDK tools for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK. It can convert template to xls with spreadsheet sdk in C#.

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 Data Extraction Suite for convert template to xls with spreadsheet sdk below and use it in your application. Follow the instructions from scratch to work and copy the C# code. Complete and detailed tutorials and documentation are available along with installed ByteScout Data Extraction Suite if you’d like to learn more about the topic and the details of the API.

Trial version of ByteScout Data Extraction Suite is available for free. Source code samples are included to help you with your C# app.

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 Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction 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 Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next