XAF Excel Data Import Module Instructions and source code, xaf Data Import
I have imported Excel Data in the XAF project. I may not use the new spreadsheet control in Devexpress. D
Well, let's take a look: It's a Web version.
The following is the win version. Currently, only the Ribbon UI is supported. The next version supports other interfaces:
Function Description:
Data can be imported from any version of Excel. You can use the open file function to select an existing file. If there is no template, please go to the interface and save it as Excel to a local file to add data to the template.
The display name is used for matching fields during import, so do not modify the field.
The validation rules you have written will be used during import.
Windows and Web versions are supported.
Usage:
Step 1: drag the Admiral. ImportData Module to the Module of your project. For example, I will drag Admiral. ImportData to project A, that is, MFBI. Module.
Step 2: Drag Admiral. ImportData. Web to B.
Step 3: Drag Admiral. ImportData. Win to C.
You don't know where the module is located? See:
Open Module. cs in solution, and drag ImportDataModule from toolbox to Required Modules.
Of course, this is the method to put the source code directly into the project. If you want to directly use DLL, You can compile the code, add the selection item in toolbox, select the path, and then drag it.
Let's take a look at the settings in the Code:
The following code has two marked red points. First, you must implement the IImportData interface to import data. This interface is empty and does not need to be implemented. DomainComponent can also be used in this way.
There are no other settings for common fields.
For referenced fields, [importdefadefafiltercriteria ("encoding =? ")] In this way, to set the conditions used to search for reference type values in the future. Of course, the question mark will be replaced with the true value in Excel.
[xafdisplayname]
[navigationitem ("sales module")]
Public class sales details: baseobject, iimportdata
{
Public sales details (session s): base (s)
{
}
Private order;
[Association]
[importdefaultfiltercriteria ("code =?" ")]
Public order
{
Get {return order;}
Set {setpropertyvalue ("order", ref {order, value);}
}
...
}
The current module is relatively simple and will be improved in the future.
Source code download
Welcome to the XAF technology exchange group to discuss XAF technology application 50185791, QQ: 4603528
Indicate the source for reprinting. Thank you!