VCL.Net 之家

探讨VCL.Net的技术,特别是从VCL迁移到VCL.Net的经验和技巧

导航

Import from Excel - Continue 1

Here comes a solution:
For each import sheet:
1. Copy the sheet inot a temp table in the database(SQL Server)
2. Run distribution SQL scripts to distribute the data from the temp table into other existing table
3. Drop tem table

Base on above solution, for any import job, only the scripts need to be changed to do the distribution.
This solution is providing convenience to the developer not to the end user. Developer can build a seperated tool to do the import job. The tool needs some information to do the import job:
1. How to connect to the destination database
2. Which import job? This infomation is used to identify the corresponding SQL scripts need to be run.
3. File name of the excel file which hold the data to be imported

The destination database must be specified by the end user, so this info is gained by interactive with the end user. Same as the  file name. The tool needs a configuration file to hold the scripts for all import jobs. XML can be one of the candidates. A simple one will look like below:

<?xml version="1.0" encoding="UTF-8"?>
<OMCSInternational>
 <Import name="Import Task" DB="SQLServer">
  <FromExcel>
   <Sheet name="sheet1" temptable = "ImportHelpTask">
    <Distribution id="ImportInterval" name="Import Intervals" order="1">
       insert into [Interval]([Interval] ) select distinct [Interval] from ImportHelpTask where [Interval] not in (select [Interval] from [Interval]) 
    </Distribution>
    <Distribution id="ImportTrade" name="Import Trades" order="2">
        ...
    </Distribution>
   </Sheet>
  </FromExcel> sheet="sheet1"/>
 </Import>
 <Import name="Import Equipment" DB="SQLServer">
   ...
 </Import>
</OMCSInternational>

In conclusion, the tool lists all it supports import task, when end user selects a task and provides a excel sheet as well as the info to connect to the databse, it will import the data in the sheet base on the scripts.

posted on 2006-07-14 09:07  Bo Chen Lin  阅读(587)  评论(0编辑  收藏  举报