The present invention provides an Excel file parsing method, including: S1, using Apache POI to extract file information, title information, and content information of the target Excel file, in which the file information includes at least the unique identification and file name of the target Excel file, and the title information is less including the unique identification of the target Excel file, Each column name and the number of rows corresponding to each of the listed names; the content information includes the unique identity of the target Excel file, the cell data of each column of the corresponding column and the number of rows corresponding to each cell's data; S2, records the file information, title information, and content information into the file information table, the title information table and the content. Information table. The invention provides an analytic method of Excel file, which is divided into three parts to analyze the Excel file, effectively analyze the Excel file, reduce the time cost and improve the efficiency of batch analysis.
【技术实现步骤摘要】
一种Excel文件解析方法
本专利技术涉及数据解析
,尤其涉及一种Excel文件解析方法。
技术介绍
ApachePOI是应用Java编写的免费开源的跨平台的JavaAPI,ApachePOI提供API给Java程式对MicrosoftOffice格式档案读和写的功能,特别是Java操作Excel解决方案。目前,应用ApachePOI对Excel文件进行解析已经成为Excel解析的主流方法。然而,随着项目中越来越多Excel文件的批量导入,针对单个Excel处理的工作量也越来越大。目前基于ApachePOI的Excel解析方法大都基于Excel文件整体进行,大量的解析程序耗时耗力,给批量Excel文件的解析带来了挑战。
技术实现思路
本专利技术为解决现有技术中存在的Excel文件解析方法费时费力的问题,提供了一种Excel文件解析方法。一方面,本专利技术提出一种Excel文件解析方法,包括:S1,应用ApachePOI分别提取目标Excel文件的文件信息、标题信息和内容信息;其中,所述文件信息至少包括所述目标Excel文件的唯一标识和文件名称;所述标题信息至少包括所述目标Excel文件的唯一标识、每列对应的列名和每一所述列名对应的行数;所述内容信息包括所述目标Excel文件的唯一标识、每一所述列名对应列的单元格数据和每一所述单元格数据对应的行数;S2,将所述文件信息、标题信息和内容信息对应录入文件信息表、标题信息表和内容信息表中。优选地,所述文件信息还包括所述目标Excel文件的文件类型、文件大小和文件位置中的至少一种。优选地,任一列对应的列名的获取方法 ...
【技术保护点】
1.一种Excel文件解析方法,其特征在于,包括:S1,应用ApachePOI分别提取目标Excel文件的文件信息、标题信息和内容信息;其中,所述文件信息至少包括所述目标Excel文件的唯一标识和文件名称;所述标题信息至少包括所述目标Excel文件的唯一标识、每列对应的列名和每一所述列名对应的行数;所述内容信息包括所述目标Excel文件的唯一标识、每一所述列名对应列的单元格数据和每一所述单元格数据对应的行数;S2,将所述文件信息、标题信息和内容信息对应录入文件信息表、标题信息表和内容信息表中。
【技术特征摘要】
1.一种Excel文件解析方法,其特征在于,包括:S1,应用ApachePOI分别提取目标Excel文件的文件信息、标题信息和内容信息;其中,所述文件信息至少包括所述目标Excel文件的唯一标识和文件名称;所述标题信息至少包括所述目标Excel文件的唯一标识、每列对应的列名和每一所述列名对应的行数;所述内容信息包括所述目标Excel文件的唯一标识、每一所述列名对应列的单元格数据和每一所述单元格数据对应的行数;S2,将所述文件信息、标题信息和内容信息对应录入文件信息表、标题信息表和内容信息表中。2.根据权利要求1所述的方法,其特征在于,所述文件信息还包括所述目标Excel文件的文件类型、文件大小和文件位置中的至少一种。3.根据权利要求1所述的方法,其特征在于,任一列对应的列名的获取方法包括:顺序读取所述目标Excel文件中包含数据的第一行单元格,并根据预先设定的命名规则和任一所述单元格的列号设置所述任一单元格所在列的列名。4.根据权利要求2所述的方法,其特征在于,所述文件类型至少包括.xlsx和.xls。5.根据权利要求1所述的方法,其特征在于,还包括:S3,应用所述文件信息表、标题信息表和内容信息表对所述目标Excel文...
【专利技术属性】
技术研发人员:安焕龙,
申请(专利权)人:北京市天元网络技术股份有限公司,
类型:发明
国别省市:北京,11
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。