Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example saves the Spread data shown to a tab-delimited file (tabbed.txt) and then to a delimited file (delimiters.txt). The project form would appear as shown in the following picture.

The tab-delimited file (tabbed.txt) will have the following format:

Place[tab]Swim[tab]Bike[tab]Run
First[tab]12:20[tab]38:47[tab]17:12
Second[tab]12:40[tab]39:55[tab]18:01

The file with column and row delimiters (delimiters.txt) will have the following format:

Place,Swim,Bike,Run
First,12:20,38:47,17:12
Second,12:40,39:55,18:01

To access the file used in this sample, change the path in the code to the path for your product installation's \SAMPLES\FILES directory.

C++

void CExportToTextFileDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
    CDialog::OnShowWindow(bShow, nStatus);
    BOOL ret;

    // Label command buttons
    m_Command1.SetWindowText("Export to tab-delimited file");
    m_Command2.SetWindowText("Export to delimited file");
    // Load data in sheet
    ret = m_Spread.LoadFromFile("place.ss7");
}

void CExportToTextFileDlg::OnButton1()
{
    BOOL ret;

    // Save to a tab-delimited file
    ret = m_Spread.ExportToTextFile("tabbed.txt", "", "\t", "\r", ExportToTextFileColHeaders || ExportToTextFileCreateNewFile, "tabbed.log");
}

void CExportToTextFileDlg::OnButton2()
{
    BOOL ret;

    // Save to a file using column and row delimiters.
    ret = m_Spread.ExportToTextFile("delimiters.txt", "", ",", "\r", ExportToTextFileColHeaders || ExportToTextFileCreateNewFile, "delimiters.log");
}

Visual Basic

Private Sub Command1_Click()
    Dim ret As Boolean
    ' Save to a tab-delimited file
    ret = fpSpread1.ExportToTextFile("C:\Samples\tabbed.txt", "", Chr(9), Chr(13), ExportToTextFileColHeaders + ExportToTextFileCreateNewFile, "C:\Samples\tabbed.log")
End Sub

Private Sub Command2_Click()
    Dim ret As Boolean
    ' Save to a file using column and row delimiters.
    ret = fpSpread1.ExportToTextFile("C:\Samples\delimiters.txt", "", ",", Chr(13), ExportToTextFileColHeaders + ExportToTextFileCreateNewFile, "C:\Samples\delimiters.log")
End Sub

Private Sub Form_Load()
    ' Label command buttons
    Command1.Caption = "Export to tab-delimited file"
    Command2.Caption = "Export to delimited file"
    ' Load data in sheet
    Dim ret As Boolean
    ret = fpSpread1.LoadFromFile("C:\Samples\Files\place.ss7")
End Sub

Copyright © GrapeCity, inc. All rights reserved.