ByteScout Spreadsheet SDK - C# - Merge Two Documents - ByteScout

ByteScout Spreadsheet SDK – C# – Merge Two Documents

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Merge Two Documents

How to merge two documents in C# using ByteScout Spreadsheet SDK

How to merge two documents in C#

On this page you will learn from code samples for programming in C#.Writing of the code to merge two documents in C# can be done by developers of any level using ByteScout Spreadsheet SDK. Want to merge two documents in your C# app? ByteScout Spreadsheet SDK is designed for it. ByteScout Spreadsheet SDK is the SDK to create, read, modify and calculate spreadsheets. Formula calculations are supported, import and export to and from JSON, CSV, XML, databases, arrays.

This rich sample source code in C# for ByteScout Spreadsheet SDK includes the number of functions and options you should do calling the API to merge two documents. Just copy and paste the code into your C# application’s code and follow the instruction. Implementing C# application typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.

Trial version of ByteScout Spreadsheet SDK can be downloaded for free from our website. It also includes source code samples for C# and other programming languages.

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.Collections.Generic; using System.Text; using Bytescout.Spreadsheet; using System.Diagnostics; using System.IO; namespace Sample { class Program { static void Main(string[] args) { // Open existing Spreadsheets Spreadsheet document1 = new Spreadsheet(); document1.LoadFromFile("workbook1.xls"); Spreadsheet document2 = new Spreadsheet(); document2.LoadFromFile("workbook2.xls"); // Create output document Spreadsheet document3 = new Spreadsheet(); // Add new worksheet document3.Workbook.Worksheets.Add(); // Target row int targetRow = 0; // Copy cells from first document for (int i = 0; i < 10; i++) { for (int j = 0; j < 12; j++) { document3.Worksheet(0).Cell(targetRow, j).Value = document1.Worksheet(0).Cell(i, j).Value; } targetRow++; } // Copy cells from second document for (int i = 0; i < 10; i++) { for (int j = 0; j < 12; j++) { document3.Worksheet(0).Cell(targetRow, j).Value = document2.Worksheet(0).Cell(i, j).Value; } targetRow++; } // delete output file if exists already if (File.Exists("Output.xls")){ File.Delete("Output.xls"); } // Save document document3.SaveAs("output.xls"); // Close document document3.Close(); // Open document in default xls viewer Process.Start("Output.xls"); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Explore Samples

Sign Up for ByteScout Spreadsheet SDK 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 Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Explore Samples

Sign Up for ByteScout Spreadsheet SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next