Program Guide

Program Guide (1)

Spire.Spreadsheet is a .NET Excel viewer control that allows programmers to load Excel spreadsheet in Windows form, manipulate the data in it and save to file. This guide will introduce how to add Spire.Spreadsheet controls to Toolbox and how to create a Windows Form Application to display Excel spreadsheet.

Add Spire.Spreadsheet Controls to Toolbox

Right-click on the white space of the Toolbox – "Add Tab" - name the new Tab "Spire.Spreadsheet Controls":

Add Spire.Spreadsheet Controls to Toolbox

Right-click on the blank part below "Spire.Spreadsheet Controls" - "Choose Items" - ".NET Framework Components" - "Browse" to the "Bin" folder - find the file "Spire.Spreadsheet.dll" - "Open".

Add Spire.Spreadsheet Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

Add Spire.Spreadsheet Controls to Toolbox


Create a Windows Form Application to Display Spreadsheet

Create a Windows Form Application, drag Spreadsheet control to form1 and add an openToolStrip in menuStrip to open an Excel file.

Create a Windows Form Application to Display Spreadsheet

Double click openToolStrip to write code. The spreadsheet1 that represents Spreadsheet control can easily load an Excel file by LoadFromFile() method.

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
    OpenFileDialog ofDialog = new OpenFileDialog();
    ofDialog.Filter = "All files|*.*|Microsoft Excel Files(*.xls;*.xlsx;*.ods;*.xlsb)|*.xls;*.xlsx;*.xlsb;*.ods";
    if (ofDialog.ShowDialog() == DialogResult.OK)
        spreadsheet1.LoadFromFile(ofDialog.FileName);
}

Run the program and open an existing Excel file, you’ll get following output:

Create a Windows Form Application to Display Spreadsheet

page