DoneEx
Home arrow XCell Compiler arrow How To arrow Export/Import Data
May 22, 2013 at 11:13 AM
Home
XCell Compiler
Advanced Search
Export/Import Changed Data

Once you compile your excel file, it creates an application (EXE File) where there is the possibility to export/import changed data for the application.
The Export/Import of changed data is allowed if the EXE application was compiled with "Allow Export/Import"  option on.
For example, when the compiled application 'Sample.exe' runs, the following menu appears on Excel.

 

Export/Import menu

Please note that the 'Export Data' item is grayed. It will be activated as soon as any data will be changed on spreadsheet because the option allows to export changed data only.

  • Export Data : By clicking the 'Export Data' menu, the windows standard save dialog will appear, type a file name in order to export. The export file will be in binary format with .dat extension. The file contains only the data, which are different from the original application data.

    For EXE application the export option works for changed data only. If you want to export non-changed data  just   make copy-cut and paste exactly at same place for such data.

  • Export Collected Data: This item works same way as Export Data with exception that it exports all changes were made and collected since the beginning of the EXE file usage.
    If one cell during this time was modified more than ones then will be exported the latest value.
  • Import Data: By clicking the 'Import Data' menu, the following dialog will appear.

Import dialog

Select the file you want to import for your application, it will import the values into cells, if  you would like to see the imported values in different back ground or font color, you may choose the colors before importing.

If you would like to import data into original xls file then go to the Excel main menu ->DoneEx ->XCell Compiler -> Load external data
In this case the data will be imported into active workbook.
Please note that data in cells, where the imported data come, will be rewritten.

If you would like to import data into EXE application then please go Excel main menu ->DoneEx ->Application name ->Import Data.

The following warning appears in case if you made export data from EXE with one control sum inside and import data into EXE with another control sum..

Wrong import data

The control sum calculates from all formulas of xls during compilation.
If you change even one symbol in any formula of your xls model then the control sum after compilation will be changed. In another words the Compiler detects that the data were taken from one workbook and are trying to be imported into another workbook.
This warning cannot be removed or stopped. If you agree to continue import then the correct work of your EXE file cannot be guaranteed.

If you like to involve Export/Import from VBA code then you may use the following piece of code.  Please note that this VBA code will work only for compiled EXE application.

Private Sub Import_Click()
    Dim mainCmdBar As CommandBar
    Dim dnx As CommandBarPopup
    Dim appBtn As CommandBarPopup
    Dim loadBtn As CommandBarControl
    Set mainCmdBar = Application.CommandBars.Item("Worksheet Menu Bar")
    Set dnx = mainCmdBar.FindControl(, ,"DoneEx_MainMenu_Item_Tag")
    If Not dnx Is Nothing Then
        For i = 1 To dnx.Controls.Count
            If dnx.Controls.Item(i).Tag ="DoneEx_Package_Submenu" Then
                Set appBtn = dnx.Controls.Item(i)
                Exit For
            End If
        Next
        If Not appBtn Is Nothing Then
            Set loadBtn = appBtn.Controls.Item(2)
            If Not loadBtn Is Nothing Then
                loadBtn.Execute 'load data
            End If
        End If
    End If
End Sub

Private Sub Export_Click()
    Dim mainCmdBar As CommandBar
    Dim dnx As CommandBarPopup
    Dim appBtn As CommandBarPopup
    Dim expBtn As CommandBarControl

    Set mainCmdBar =Application.CommandBars.Item("Worksheet Menu Bar")
    Set dnx = mainCmdBar.FindControl(, ,"DoneEx_MainMenu_Item_Tag")
    If Not dnx Is Nothing Then
        For i = 1 To dnx.Controls.Count
            If dnx.Controls.Item(i).Tag ="DoneEx_Package_Submenu" Then
                Set appBtn = dnx.Controls.Item(i)
                Exit For
            End If
        Next
        If Not appBtn Is Nothing Then
            Set expBtn = appBtn.Controls.Item(1)
            If Not expBtn Is Nothing Then
                If expBtn.Enabled Then
                    expBtn.Execute  'save data
                End If
            End If
        End If
    End If
End Sub

 

Copyright 2005 - 2012 DoneEx .