ByteScout Data Extraction Suite - C# - Import from dataset 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# – Import from dataset with spreadsheet sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – C# – Import from dataset with spreadsheet sdk

How to import from dataset with spreadsheet sdk in C# using ByteScout Data Extraction Suite

Learn to import from dataset with spreadsheet sdk in C#

This sample source code below will display you how to import from dataset with spreadsheet sdk in C#. What is ByteScout Data Extraction Suite? It 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 help you to import from dataset with spreadsheet sdk in your C# application.

The SDK samples given below describe how to quickly make your application do import from dataset with spreadsheet sdk in C# with the help of ByteScout Data Extraction Suite. Just copy and paste the code into your C# application’s code and follow the instructions. Further improvement of the code will make it more robust.

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.Data; using System.Diagnostics; using System.IO; namespace Bytescout.Spreadsheet.Demo.Csharp.ImportFromDataSet { class Program { static void Main(string[] args) { const string fileName = "CSharpImportFromDataSet.xls"; // Create a new spreadsheet Spreadsheet spreadsheet = new Spreadsheet(); // Get the data from the dataset that we wish to import DataSet periodicTableAndScientists = GetDataSet(); // Import data into spreadheet spreadsheet.ImportFromDataSet(periodicTableAndScientists); // Insert row with column captions for (int i = 0; i < periodicTableAndScientists.Tables.Count; i++) { DataTable dataTable = periodicTableAndScientists.Tables[i]; Worksheet worksheet = spreadsheet.Worksheets[i]; worksheet.Rows.Insert(0); for (int colIndex = 0; colIndex < dataTable.Columns.Count; colIndex++) { worksheet.Cell(0, colIndex).Value = dataTable.Columns[colIndex].Caption; } } // Save the spreadsheet if (File.Exists(fileName)) File.Delete(fileName); spreadsheet.SaveAs(fileName); // Close spreadsheet spreadsheet.Close(); // Open the spreadsheet Process.Start(fileName); } /// <summary> /// Creates a data set of the periodic table of elements and some famous scientists /// </summary> /// <returns>A data set of the periodic table of elements and some scientists</returns> private static DataSet GetDataSet() { DataTable periodicTable = GetDataTableOfElements(); DataTable scientists = GetDataTableOfScientists(); DataSet dataset = new DataSet(); dataset.Tables.Add(periodicTable); dataset.Tables.Add(scientists); return dataset; } /// <summary> /// Creates a data table of the periodic table of elements /// </summary> /// <returns>A data table of the periodic table of elements</returns> private static DataTable GetDataTableOfElements() { DataTable periodicTable = new DataTable("PeriodicTable"); periodicTable.Columns.Add("Name", typeof(string)); periodicTable.Columns.Add("Symbol", typeof(string)); periodicTable.Columns.Add("AtomicNumber", typeof(int)); DataRow dr = periodicTable.Rows.Add(); dr[0] = "Hydrogen"; dr[1] = "H"; dr[2] = "1"; dr = periodicTable.Rows.Add(); dr[0] = "Helium"; dr[1] = "He"; dr[2] = "2"; dr = periodicTable.Rows.Add(); dr[0] = "Lithium"; dr[1] = "Li"; dr[2] = "3"; dr = periodicTable.Rows.Add(); dr[0] = "Beryllium"; dr[1] = "Be"; dr[2] = "4"; dr = periodicTable.Rows.Add(); dr[0] = "Boron"; dr[1] = "B"; dr[2] = "5"; dr = periodicTable.Rows.Add(); dr[0] = "Carbon"; dr[1] = "C"; dr[2] = "6"; return periodicTable; } /// <summary> /// Creates a data table of scientists /// </summary> /// <returns>A data table of scientists</returns> private static DataTable GetDataTableOfScientists() { DataTable scientistsTable = new DataTable("Scientists"); scientistsTable.Columns.Add("Name", typeof(string)); DataRow dr = scientistsTable.Rows.Add(); dr[0] = "Antoine Lavoisier"; dr = scientistsTable.Rows.Add(); dr[0] = "Julius Lothar Meyer "; dr = scientistsTable.Rows.Add(); dr[0] = "Dmitri Ivanovich Mendeleev"; return scientistsTable; } } }

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