I have implemented the import of Excel data in the XAF project, and using DevExpress's new spreadsheet control, it may not be new: D
OK, let's take a look: It's a web version.
The following is the win version, currently only supports the Ribbon UI, the next version supports other interfaces:
Function Description:
Support to import data from any version of Excel, you can use the Open File feature to select an existing file, when there is no template, please come to the interface, Save as Excel to local, add data to the template.
The display name is used for matching fields when importing, so do not modify the fields section.
The validation rules that you are writing are used when importing.
Supports two versions of Win+web.
How to use:
First step: Drag the Admiral.importdata module into the module of your project, for example, I will drag admiral.importdata to the project A in the diagram, that is, the mfbi.module.
Step Two: Drag the Admiral.ImportData.Web to B.
Step three: Drag the Admiral.ImportData.Win to C.
You don't know where the module is? Please see:
First open the Module.cs in solution, then drag Importdatamodule from toolbox to required modules.
Of course, this is to put the source code directly into the project, if you want to directly use the DLL, you can compile, in the toolbox to fill in the selection, select the path, and then drag.
Then look at the settings in the code:
There are two red in the following code, the first must implement the Iimportdata interface can be imported, this interface is empty, do not need to implement. DomainComponent can also be used in this way.
For normal fields, there are no other settings.
For reference fields, [Importdefaultfiltercriteria ("encoded =?")] That way, when you set a value for a reference type in the future, what criteria are used for the lookup, and of course the question mark is replaced with the true value in Excel.
[Xafdisplayname ("Sales Breakdown")] [Navigationitem ("Sales Module")] Public classSales Detail: baseobject,iimportdata { PublicSales Breakdown (Session s):Base(s) {}PrivateOrders _ orders; [Association]
[Importdefaultfiltercriteria ("encoding =?")] PublicOrder Order {Get{return_ orders;} Set{setPropertyValue ("Order",ref_ order, value); } } ...... }
The current module is also relatively simple, will be gradually improved in the future.
SOURCE download
Welcome to the XAF Technical Exchange Group discussion on the application of XAF technology 50185791, qq:4603528
Reprint please indicate the source. Thanks a lot!
XAF Excel Data Import module usage instructions and source code