两种非匀质Excel表转换成关系数据库表的方法
2020-05-21方木云赵长鲜张祝梦
方木云 赵长鲜 张祝梦



摘 要:依据表中数据的特点,Excel表可以分为匀质和非匀质两种类型,而关系数据库表只有匀质一种类型,所以非匀质的Excel表数据不能直接导入到关系数据库表中,需要进行表结构的匀质化转换。为了解决这一问题,提出了两种非匀质EXCEL表转换成关系数据库表的方法,实现了非匀质Excel表结构向关系数据库表结构的转换,并用C#编程实现了Excel表数据向关系数据库表的自动导入。
关键词:匀质Excel;非匀质Excel;关系数据库
中图分类号:TP311 文献标识码:A
Abstract: According to the characteristics of the data in the table, the Excel table can be divided into homogeneous and inhomogeneous types, while the relational database table has only one type, so the inhomogeneous Excel table data cannot be directly imported into the relational database table, and it is required to implement the homogenization transformation of the table structure. In order to solve this problem, the paper proposes two methods of transforming inhomogeneous Excel table into relational database table. The study achieve the transformation from inhomogeneous Excel table structure to relational database table structure, and the automatic import of Excel table data into relational database table in C# programming language.
Keywords: homogeneous excel; inhomogeneous excel; relational database
1 引言(Introduction)
Excel廣泛应用在日常办公的数据处理中。Excel的一个突出特点是采用表格方式管理数据,所有的数据和信息都以工作表的二维表格形式管理,单元格中数据间的相互关系一目了然。很多信息系统早期都是使用Excel来进行管理,不少单位的财务系统甚至到现在还在使用Excel。随着可视化编程语言和关系数据库的出现,很多应用系统开始向C/S (Client/Server)和B/S (Browser/Server)模式的信息管理系统迁移,Excel系统逐渐被替代。尽管Excel表跟关系数据库表一样采用二维表管理数据,可是很多Excel表数据不能行列对应地转换成关系数据库表数据。如何将单位内部已经使用多年的各种Excel表结构快速有效地转化成关系数据库的表结构并实现数据自动导入是一个重要的应用问题[1-9]。
关系数据库表只提供数据标准化管理,不提供自由编辑,其列数据类型约束强,一列只能全部填写数字或者全部填写文字;而Excel对列数据类型不强制约束,一列可以填写数字、文字或为空。……
