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.

Try ByteScout Spreadsheet SDK today: Get 60 Day Free Trial or sign up for Web API

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

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

VIDEO

ON-PREMISE VERSION

Get 60 Day Free Trial or Visit ByteScout Spreadsheet SDK page

Explore ByteScout Spreadsheet SDK documentation

WEB API

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next