To view a printable version of this article in a PDF viewer,
click here for PDF.
This tutorial guides you through the process of deciding how you want to add your data to Spread. It then steps you through the procedures appropriate for your situation.
FarPoint Spread is a powerful spreadsheet/grid control from FarPoint Technologies. This tutorial describes the various ways to add data to a Spread control. You might want to read this tutorial if you want to understand more about Spread's features for adding data.
Throughout the tutorial, we assume that you are familiar with the Microsoft® Visual Basic® development environment and with basic Spread features, such as adding the control to your toolbox, putting the control on a form, and working with cell types. We also assume that you have installed the Spread ActiveX control. If you are using another development environment or control, the concepts presented in the tutorial may still be useful to you.
This tutorial is based on the features provided in Spread COM for versions 3.5 and higher. However, much of the information is correct for earlier versions of Spread.
The Spread control offers several ways to add data to Spread:
- Binding to a database and bringing in its records automatically
- Adding data in code
- Loading an existing file
- Ways of adding data to Spread

This tutorial describes these different ways of adding data to Spread and also provides:
- Guidelines for deciding when to use the different ways of adding data
- Information about data validation
- An introduction to data formatting
Back to
the top.
Deciding How to Add Data to Spread
|
In This Section:
You learn some of the factors influencing how you add data to Spread.
You begin deciding how to add data by determining the source of your data.
|
Influencing Factors
- Many factors can influence how you choose to add data to Spread. Factors include:
- The form of the data to add. For example, your data may be formatted or unformatted.
- The destination cell type. Different cell types format data in different ways.
- The number of rows and columns. Consider using virtual mode for large datasets. For more information about virtual mode, see the Spread User's Guide or the white paper "Using Virtual Mode in Spread," available on the FarPoint web site .
- How fast you want the data to load. For example, data binding can be slower than just clipping records in.
- How you want to access the data after it's loaded. For example, if you need to be able to find records in the spreadsheet or persist the changes made to the data, then binding could be the best solution. The Recordset object supports methods for finding particular records, and Spread will write back changes made automatically (unless you override it).
- Your development environment. Some environments, such as HTML and Visual C++® 1.5, do not offer a data control.
The tables in this tutorial help you sort through many of these factors.
Determining the Source of Your Data
Use the following table to help you decide how to best add data to Spread, based on the source of the data.
|
TABLE 1.Start Here to Add Data to Spread
|
|
Where is your data?
|
Then, do this ...
|
See these instructions ...
|
|
In a database
|
Bind the database to the Spread control.
|
"Bringing in Data Automatically by Binding to a Database"
|
|
In code, such as string values or an array.
|
Is your data formatted or unformatted? (To help you decide, see
What is Formatted and Unformatted Data?.)
|
If your data is formatted, add the formatted data.
|
Adding Formatted Data
|
|
If your data is unformatted, add the unformatted data.
|
Adding Unformatted Data
|
|
In an existing file, such as a Spread file, an Excel file, or a tab-delimited file
|
Load the existing file.
|
Loading an Existing File
|
Back to
the top.
Bringing in Data Automatically by Binding to a Database
|
In This Section:
You understand how simple it is to bind to a database with Spread, a data-aware control.
You learn what data-aware controls are.
You read an overview of the steps for binding to a database.
You step through an example of binding the Spread control to a database.
|
Introduction to Binding with Spread
In Spread's simplest form, you can view and edit any database supported by Visual Basic by following these simple steps:
Attach the Visual Basic Data control to the database.
Connect the Spread control to the Data control.
Run your application!
Spread, being a data-aware control, makes it very easy to bind to a database to bring in data automatically.
Back to
the top.
What are Data-Aware (Bound) Controls?
Basics
Some type of database is at the core of many, if not most, modern software applications. Before data-aware controls, developers manipulated databases using extensive coding to extract the data from the database and then populate the fields of a form. Extensive coding was also required to allow the user to browse the data, capture the user's changes to the data, and then write the changes back to the database.
The concept of data-aware, or bound, controls eliminated much of this tedious coding. Now, developers can simply bind a field on a form to a Data control and specify a database table to use. For example, a text box that displays an employee's last name might be bound to the LastName field in the Employee table. The Data control handles the tasks of receiving and saving the data, and the control automatically performs navigation functions such as letting the user step back and for