WO2022105478A1 - 在线预览excel文件方法、装置、电子设备及存储介质 - Google Patents

在线预览excel文件方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2022105478A1
WO2022105478A1 PCT/CN2021/123177 CN2021123177W WO2022105478A1 WO 2022105478 A1 WO2022105478 A1 WO 2022105478A1 CN 2021123177 W CN2021123177 W CN 2021123177W WO 2022105478 A1 WO2022105478 A1 WO 2022105478A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
excel
excel file
sheet
content
Prior art date
Application number
PCT/CN2021/123177
Other languages
English (en)
French (fr)
Inventor
张依
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2022105478A1 publication Critical patent/WO2022105478A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing

Definitions

  • the present application relates to the field of artificial intelligence technology and big data technology, and in particular, to a method, apparatus, electronic device, and computer-readable storage medium for online previewing of excel files.
  • excel file is a relatively important basic file.
  • a method for online previewing an excel file provided by this application includes:
  • the content data of the excel file is stored in the database
  • the content data of the corresponding excel file is obtained by searching the database according to the online preview request of the file, and the content data is displayed on a pre-built page according to a preset format.
  • the present application also provides a device for previewing an excel file online, the device comprising:
  • the file acquisition module is used to acquire the excel file that needs to be previewed
  • a content analysis module configured to perform content analysis on the excel file to obtain content data corresponding to the excel file
  • a data saving module for saving the content data of the excel file into a database
  • the request receiving module is used to receive the file online preview request
  • the content display module is configured to search the database for content data of the corresponding excel file according to the online preview request of the file, and display the content data on a pre-built page according to a preset format.
  • the present application also provides an electronic device, the electronic device comprising:
  • a processor that executes computer program instructions stored in the memory to achieve the following steps:
  • the content data of the excel file is stored in the database
  • the content data of the corresponding excel file is obtained by searching the database according to the online preview request of the file, and the content data is displayed on a pre-built page according to a preset format.
  • the present application also provides a computer-readable storage medium storing a computer program, and the computer program is executed by a processor to implement the following steps:
  • the content data of the excel file is stored in the database
  • the content data of the corresponding excel file is obtained by searching the database according to the online preview request of the file, and the content data is displayed on a pre-built page according to a preset format.
  • FIG. 1 is a schematic flowchart of a method for online previewing an excel file provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a module of a device for online previewing an excel file provided by an embodiment of the present application
  • FIG. 3 is a schematic diagram of the internal structure of an electronic device for implementing a method for online previewing an excel file provided by an embodiment of the present application;
  • AI artificial intelligence
  • digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
  • the basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation/interaction systems, and mechatronics.
  • Artificial intelligence software technology mainly includes computer vision technology, robotics, biometrics, speech processing, natural language processing, and machine learning/deep learning.
  • An embodiment of the present application provides a method for online previewing an excel file.
  • the execution body of the online preview of the excel file includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiment of the present application, such as a server and a terminal.
  • the method for previewing an excel file online may be executed by software or hardware installed on a terminal device or a server device, and the software may be a blockchain platform.
  • the server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
  • FIG. 1 a schematic flowchart of a method for online previewing an excel file provided by an embodiment of the present application.
  • the method for online previewing an excel file includes:
  • the excel files to be previewed in the embodiments of the present application include the excel files saved in the server and the excel files uploaded by the user.
  • the obtaining of the excel file to be previewed includes:
  • the excel file that needs to be previewed is an excel file saved in the server, obtain the path of the excel file that needs to be previewed, and obtain the excel file that needs to be previewed according to the path;
  • the excel file to be previewed is the excel file uploaded by the user
  • the excel file to be previewed is obtained by receiving the excel file uploaded by the user.
  • the excel file that needs to be previewed before acquiring the excel file that needs to be previewed, it also includes judging the type of the excel file that needs to be previewed, which specifically includes: judging the type of the excel file that needs to be previewed through parameters, when the parameters include: In the case of an excel file, it is determined that the excel file to be previewed is an excel file uploaded by the user; otherwise, it is determined that the excel file to be previewed is an excel file saved in the server.
  • the parameter is parameter data sent by the client.
  • the S2 includes:
  • the types of the excel files include xls files and xlsx files, and different object classes and different methods are used to obtain excel content according to different types of the excel files.
  • the object class is an object class in java that can directly operate the excel file type, including HSSFWorkBook for operating xls files and XSSFWorkBook for operating xlsx files.
  • the method before creating the corresponding object class according to the type of the excel file, the method further includes: determining the type of the excel file.
  • the determining the type of the excel file specifically includes: obtaining the file name of the excel file; obtaining the suffix name of the excel file according to the file name; when the suffix name is xls, determining that the excel file is xls file; when the suffix name is xlsx, it is determined that the excel file is an xlsx file.
  • obtaining the content data of the excel according to the object class includes:
  • the sheet contents of the excel are obtained;
  • the content data of the excel is obtained by assembling the sheet content and the sheet name.
  • the preset separator is a preset specified character string, such as "
  • the multiple sheet contents of the excel file are saved using a separator, which is beneficial to subsequent display on the front-end page.
  • the embodiment of the present application further includes: creating a data table in the database, where the data table includes fields of table name, sheet name and excel content.
  • the storing of the content data of the excel file in the database includes: storing the content data of the excel file in the database according to the fields of the pre-created data table.
  • one piece of data in the database represents one excel file and the corresponding content of the excel file.
  • the content data of the excel file may also be stored in a node of a blockchain.
  • the content and styles of multiple sheets of multiple excel are parsed, and the parsed content is stored in the database in a specific manner, so that the front-end page can directly obtain data from the database, which can improve efficiency.
  • the file online preview request in the embodiment of the present application is a data request generated by the user clicking the file online function under the corresponding file on the front-end page
  • the file online preview request includes the data request generated by the user when uploading the file and the user A data request made when downloading a file.
  • file online preview request includes parameters such as file name and file address.
  • the corresponding file content data can be directly obtained from the database, and displayed on a pre-built page in a certain format. superior.
  • the page described in the embodiment of the present application is a display page of the client, which is used to display an excel file, and can be constructed by using various front-end frameworks.
  • the corresponding excel file content data is obtained by searching in the database, including:
  • the sheet name and sheet content in the data are cut according to a preset separator to obtain multiple sheet name arrays and corresponding multiple sheet content arrays;
  • the multiple sheet name arrays and the corresponding multiple sheet content arrays are combined to obtain the content data of the excel file, and the content data of the excel file is returned.
  • displaying the content data on a pre-built page according to a preset format includes:
  • the content data of the excel file is correspondingly displayed on the pre-built page through the preset tags of the double-nested loop.
  • the content data of the excel file is correspondingly displayed on the pre-built page through the preset label of the double-nested loop, including:
  • the preset tag is a specific tag used to display the front-end page, such as ⁇ el-tabs>.
  • multiple excel files can be previewed online at the same time, wherein the excel file can contain multiple sheet pages, and can be displayed on the page in the form of multiple tab pages, instead of displaying all the multiple sheet pages. Displayed on one page, it is convenient for users to view the data in the excel file.
  • the embodiment of the present application obtains the excel file that needs to be previewed in advance, and analyzes the content of the excel file to obtain the content data corresponding to the excel file, and saves the content data of the excel file to the database to avoid every time
  • the excel file needs to be parsed every time, which improves work efficiency and saves computer resources; at the same time, after receiving the file online preview request, you can directly find the corresponding content from the database, which is simple and convenient, and you can obtain data through the database at one time.
  • Obtaining multiple excel files, as well as obtaining the contents of multiple sheet pages in an excel file displays them in a preset format, which is more clear and concise, and can improve development efficiency. Therefore, the embodiment of the present application can achieve the purpose of previewing the excel file online quickly and efficiently.
  • FIG. 2 it is a functional block diagram of the device for online previewing an excel file of the present application.
  • the online previewing excel file apparatus 100 described in this application can be installed in an electronic device.
  • the online preview excel file device may include a file acquisition module 101 , a target content analysis module 102 , a data storage module 103 , a request reception module 104 and a content display module 105 .
  • the modules described in the present invention can also be called units, which refer to a series of computer program segments that can be executed by the electronic device processor and can perform fixed functions, and are stored in the memory of the electronic device.
  • each module/unit is as follows:
  • the file obtaining module 101 is used to obtain the excel file that needs to be previewed.
  • the excel files to be previewed in the embodiments of the present application include the excel files saved in the server and the excel files uploaded by the user.
  • the file acquiring module 101 when acquiring the excel file that needs to be previewed, the file acquiring module 101 performs the following operations:
  • the excel file that needs to be previewed is an excel file saved in the server, obtain the path of the excel file that needs to be previewed, and obtain the excel file that needs to be previewed according to the path;
  • the excel file to be previewed is the excel file uploaded by the user
  • the excel file to be previewed is obtained by receiving the excel file uploaded by the user.
  • the excel file that needs to be previewed before acquiring the excel file that needs to be previewed, it also includes judging the type of the excel file that needs to be previewed, which specifically includes: judging the type of the excel file that needs to be previewed through parameters, when the parameters include: In the case of an excel file, it is determined that the excel file to be previewed is an excel file uploaded by the user; otherwise, it is determined that the excel file to be previewed is an excel file saved in the server.
  • the parameter is parameter data sent by the client.
  • the content analysis module 102 is configured to perform content analysis on the excel file to obtain content data corresponding to the excel file.
  • the content parsing module 102 is specifically used for:
  • the binary byte stream is written into the object class, and the content data of the excel is acquired according to the object class.
  • the types of the excel files include xls files and xlsx files, and different object classes and different methods are used to obtain excel content according to different types of the excel files.
  • the object class is an object class in java that can directly operate the excel file type, including HSSFWorkBook for operating xls files and XSSFWorkBook for operating xlsx files.
  • the method before creating the corresponding object class according to the type of the excel file, the method further includes: determining the type of the excel file.
  • the determining the type of the excel file specifically includes: obtaining the file name of the excel file; obtaining the suffix name of the excel file according to the file name; when the suffix name is xls, determining that the excel file is xls file; when the suffix name is xlsx, it is determined that the excel file is an xlsx file.
  • the content parsing module 102 is specifically used for:
  • the sheet contents of the excel are obtained;
  • the content data of the excel is obtained by assembling the sheet content and the sheet name.
  • the preset separator is a preset specified character string, such as "
  • the multiple sheet contents of the excel file are saved using separators, which is beneficial to subsequent display on the front-end page.
  • the data saving module 103 is configured to save the content data of the excel file into a database.
  • the embodiment of the present application further includes: creating a data table in the database, where the data table includes fields of table name, sheet name and excel content.
  • the data saving module 103 is specifically configured to: store the content data of the excel file in the database correspondingly according to the fields of the pre-created data table middle.
  • one piece of data in the database represents one excel file and the corresponding content of the excel file.
  • the content data of the excel file may also be stored in a node of a blockchain.
  • the content and styles of multiple sheets of multiple excel are parsed, and the parsed content is stored in the database in a specific manner, so that the front-end page can directly obtain data from the database, which can improve efficiency.
  • the request receiving module 104 is configured to receive a file online preview request.
  • the file online preview request in the embodiment of the present application is a data request generated by the user clicking the file online function under the corresponding file on the front-end page
  • the file online preview request includes the data request generated by the user when uploading the file and the user A data request made when downloading a file.
  • file online preview request includes parameters such as file name and file address.
  • the content display module 105 is configured to search and obtain the corresponding excel file content data in the database according to the file online preview request, and display the content data on a pre-built page according to a preset format.
  • the corresponding file content data can be directly obtained from the database, and displayed on a pre-built page in a certain format. superior.
  • the page described in the embodiment of the present application is a display page of the client, which is used to display an excel file, and can be constructed by using various front-end frameworks.
  • the content display module 105 specifically performs the following operations:
  • the sheet name and sheet content in the data are cut according to a preset separator to obtain multiple sheet name arrays and corresponding multiple sheet content arrays;
  • the multiple sheet name arrays and the corresponding multiple sheet content arrays are combined to obtain the content data of the excel file, and the content data of the excel file is returned.
  • the content display module 105 specifically performs the following operations:
  • the content data of the excel file is correspondingly displayed on the pre-built page through the preset tags of the double-nested loop.
  • the content display module 105 is specifically used for:
  • the preset tag is a specific tag used to display the front-end page, such as ⁇ el-tabs>.
  • multiple excel files can be previewed online at the same time, wherein the excel file can contain multiple sheet pages, and can be displayed on the page in the form of multiple tab pages, instead of displaying all the multiple sheet pages. Displayed on one page, it is convenient for users to view the data in the excel file.
  • FIG. 3 it is a schematic structural diagram of an electronic device implementing the method for online previewing an excel file of the present application.
  • the electronic device 1 may include a processor 10, a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as an online preview excel file program 12.
  • the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, CD etc.
  • the memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1 .
  • the memory 11 may also be an external storage device of the electronic device 1, such as a pluggable mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital Digital, SD) card, flash memory card (Flash Card), etc.
  • the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device.
  • the memory 11 can not only be used to store application software installed in the electronic device 1 and various data, such as the code of the online preview excel file program 12, etc., but also can be used to temporarily store the data that has been output or will be output.
  • the processor 10 may be composed of integrated circuits, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits packaged with the same function or different functions, including one or more integrated circuits.
  • Central Processing Unit CPU
  • microprocessor digital processing chip
  • graphics processor and combination of various control chips, etc.
  • the processor 10 is the control core (Control Core) of the electronic device. Unit), using various interfaces and lines to connect various components of the entire electronic device, by running or executing programs or modules stored in the memory 11 (for example, executing an online preview excel file program, etc.), and calling the program or module stored in the memory 11. 11 to perform various functions of the electronic device 1 and process data.
  • the bus may be a peripheral component interconnect (PCI for short) bus or an extended industry standard structure (extended). industry standard architecture, referred to as EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on.
  • the bus is configured to implement connection communication between the memory 11 and at least one processor 10 and the like.
  • FIG. 3 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 3 does not constitute a limitation on the electronic device 1, and may include fewer or more components than those shown in the figure. components, or a combination of certain components, or a different arrangement of components.
  • the electronic device 1 may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power source can be managed by the power source.
  • the device implements functions such as charge management, discharge management, and power consumption management.
  • the power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components.
  • the electronic device 1 may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
  • the electronic device 1 may also include a network interface, optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in the electronic device 1 Establish a communication connection with other electronic devices.
  • a network interface optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in the electronic device 1 Establish a communication connection with other electronic devices.
  • the electronic device 1 may further include a user interface, and the user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), optionally, the user interface may also be a standard wired interface or a wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, Organic Light Emitting Diode) Touch, etc.
  • the display may also be appropriately called a display screen or a display unit, which is used for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
  • the online preview excel file program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can realize:
  • the content data of the excel file is stored in the database
  • the content data of the corresponding excel file is obtained by searching the database according to the online preview request of the file, and the content data is displayed on a pre-built page according to a preset format.
  • the modules/units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium, and the computer-readable storage medium can be stored in a computer-readable storage medium. It is volatile and can also be non-volatile.
  • the computer-readable storage medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) ).
  • a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the following steps are implemented:
  • the content data of the excel file is stored in the database
  • the content data of the corresponding excel file is obtained by searching the database according to the online preview request of the file, and the content data is displayed on a pre-built page according to a preset format.
  • modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及人工智能技术和大数据技术,揭露了一种在线预览excel文件方法,包括:获取需要预览的excel文件;对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;将所述excel文件的内容数据保存至数据库中;接收文件在线预览请求;根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。本申请还提出了一种在线预览excel文件装置、电子设备及计算机可读存储介质。此外,本申请还涉及区块链技术,所述excel文件的内容数据可存储于区块链节点中。本申请可以实现快速、高效的在线预览excel文件功能。

Description

在线预览excel文件方法、装置、电子设备及存储介质
本申请要求于2020年11月19日提交中国专利局、申请号为CN202011302184.9、名称为“在线预览excel文件方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能技术领域和大数据技术领域,尤其涉及一种在线预览excel文件方法、装置、电子设备及计算机可读存储介质。
背景技术
在计算机网络中,很多数据保存在文件中,用户为了确保自己需要的数据在文件中,或是仅想查看某些数据,就需要文件在线预览功能。
技术问题
在各类文件中,excel文件是比较重要的基础文件,发明人意识到,目前的excel文件在线预览方法主要是通过将excel文件转换为html、PDF等再在前端页面显示,并且需要加载其他插件进行辅助展示,效率较低,且在展示时只能展示一个excel文件,若excel文件中有多个sheet时,会将所有sheet表格展示在一个网页里面,而不能按照excel文件的形式展示,不利于用户查看数据。
技术解决方案
本申请提供的一种在线预览excel文件方法,包括:
获取需要预览的excel文件;
对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
将所述excel文件的内容数据保存至数据库中;
接收文件在线预览请求;
根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
本申请还提供一种在线预览excel文件装置,所述装置包括:
文件获取模块,用于获取需要预览的excel文件;
内容解析模块,用于对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
数据保存模块,用于将所述excel文件的内容数据保存至数据库中;
请求接收模块,用于接收文件在线预览请求;
内容显示模块,用于根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
本申请还提供一种电子设备,所述电子设备包括:
存储器,存储至少一个计算机程序指令;及
处理器,执行所述存储器中存储的计算机程序指令以实现如下步骤:
获取需要预览的excel文件;
对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
将所述excel文件的内容数据保存至数据库中;
接收文件在线预览请求;
根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
本申请还提供一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行以实现如下步骤:
获取需要预览的excel文件;
对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
将所述excel文件的内容数据保存至数据库中;
接收文件在线预览请求;
根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
附图说明
图1为本申请一实施例提供的在线预览excel文件方法的流程示意图;
图2为本申请一实施例提供的在线预览excel文件装置的模块示意图;
图3为本申请一实施例提供的实现在线预览excel文件方法的电子设备的内部结构示意图;
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
本发明的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。
人工智能基础技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理技术、操作/交互系统、机电一体化等技术。人工智能软件技术主要包括计算机视觉技术、机器人技术、生物识别技术、语音处理技术、自然语言处理技术以及机器学习/深度学习等几大方向。
本申请实施例提供一种在线预览excel文件方法。所述在线预览excel文件的执行主体包括但不限于服务端、终端等能够被配置为执行本申请实施例提供的该方法的电子设备中的至少一种。换言之,所述在线预览excel文件方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。
参照图1所示,为本申请一实施例提供的在线预览excel文件方法的流程示意图。在本实施例中,所述在线预览excel文件方法包括:
S1、获取需要预览的excel文件。
本申请实施例中所述需要预览的excel文件包括保存在服务器中的excel文件和用户上传的excel文件。
详细地,所述获取需要预览的excel文件,包括:
当所述需要预览的excel文件为保存在服务器中的excel文件时,获取所述需要预览的excel文件的路径,根据所述路径获取所述需要预览的excel文件;
当所述需要预览的excel文件为用户上传的excel文件时,则通过接收用户上传的excel文件获取所述需要预览的excel文件。
在实际业务系统中,有时用户是在上传excel文件时,需要通过在线预览确定上传文件无误,有时用户是在下载excel文件时,需要确定下载文件无误,因此需要根据两种情况分别获取需要预览的excel文件。
可选地,在获取需要预览的excel文件之前,还包括对所述需要预览的excel文件的类型进行判断,具体包括:通过参数对所述需要预览的excel文件的类型进行判断,当参数中包括excel文件时,确定所述需要预览的excel文件为用户上传的excel文件;否则,确定所述需要预览的excel文件为保存在服务器中的excel文件。其中,所述参数是客户端发送的参数数据。
S2、对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据。
详细地,所述S2包括:
将所述excel文件转化为二进制字节流;
根据所述excel文件的类型创建对应的对象类;
将所述二进制字节流写入所述对象类中,并根据所述对象类获取所述excel的内容数据。
其中,所述excel文件的类型包括xls文件和xlsx文件,根据所述excel文件的类型的不同需要使用不同的对象类以及不同的方法获取excel内容。所述对象类是java中可以直接操作excel文件类型的对象类,包括用于操作xls文件的HSSFWorkBook和用于操作xlsx文件的XSSFWorkBook。
可选地,在根据所述excel文件的类型创建对应的对象类之前,还包括:确定所述excel文件的类型。所述确定所述excel文件的类型具体包括:获取所述excel文件的文件名;根据所述文件名获取所述excel文件的后缀名;在所述后缀名为xls时,确定所述excel文件为xls文件;在所述后缀名为xlsx时,确定所述excel文件为xlsx文件。
进一步地,所述根据所述对象类获取所述excel的内容数据,包括:
利用所述对象类循环遍历所述excel的多个sheet;
设置每个所述sheet页中的单元格样式,并逐行读取每个所述sheet页的内容,得到所述多个sheet对应的多个sheet内容;
将所述多个sheet内容进行汇集,并将预设的分隔符插入每个sheet内容后,得到所述excel的sheet内容;
利用所述对象类获取所述excel的所有sheet名,并在每个sheet名后添加预设的分隔符,得到所述excel的sheet名称;
将所述sheet内容和所述sheet名称汇集得到所述excel的内容数据。
其中,所述预设的分隔符是预设规定的字符串,如“||@@@||”。
本申请实施例在解析excel文件时,将excel文件的多个sheet内容使用分隔符进行保存,有利于后续在前端页面的展示。
S3、将所述excel文件的内容数据保存至数据库中。
可选地,本申请实施例在将所述excel文件的内容数据保存至数据库中之前,还包括:在数据库中创建数据表,所述数据表中包括表名,sheet名称和excel内容的字段。
详细地,本申请实施例所述将所述excel文件的内容数据保存至数据库中,包括:将所述excel文件内容数据按照预先创建的数据表的字段对应保存至数据库中。
当所述excel文件为多个时,可以循环上述操作,将多个excel文件保存至数据库中,此时,数据库中的一条数据代表一个excel文件以及对应的excel文件内容。
可选地,为保证所述excel文件的内容数据的私密和安全性,所述excel文件的内容数据还可以存储于一区块链的节点中。
本申请实施例通过解析多个excel的多个sheet页内容以及样式,以特定的方式将解析完的内容存储到数据库,使前端页面可以直接从数据库中获取数据,可以提高效率。
S4、接收文件在线预览请求。
详细地,本申请实施例中所述文件在线预览请求是用户在前端页面在对应文件下点击文件在线功能产生的数据请求,所述文件在线预览请求包括用户在上传文件时产生的数据请求和用户在下载文件时产生的数据请求。
进一步地,所述文件在线预览请求中包括文件名称、文件地址等参数。
S5、根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
可选地,本申请实施例通过提前将文件解析内容保存在数据库中,在接收到文件在线预览请求后,可直接从数据库中获取对应的文件内容数据,并以一定格式显示在预先构建的页面上。
本申请实施例中所述页面是客户端的显示页面,用于显示excel文件,可以利用多种前端框架进行构建。
详细地,所述根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容数据,包括:
获取所述文件在线预览请求中的文件名称;
根据所述文件名称在数据库中查找,得到结果数据集;
对所述结果数据集中每条数据,根据预设的分隔符将所述数据中的sheet名称和sheet内容进行切割,得到多个sheet名称数组和对应多个sheet内容数组;
将所述多个sheet名称数组和对应多个sheet内容数组合并,得到excel文件内容数据,并将所述excel文件内容数据返回。
进一步地,所述将所述内容数据按照预设的格式显示在预先构建的页面上,包括:
获取所述excel文件内容数据;
使用双层嵌套循环的预设标签进行布局,渲染页面;
通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上。
详细地,所述通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上,包括:
利用外层循环预设标签中每个标签展示所述excel文件内容中一个excel文件对应的excel文件名和excel内容;
利用内层循环预设标签中每个标签展示与当前excel文件对应的sheet名称数组中的每个sheet名称和sheet内容数组中的每个sheet内容。
其中,所述预设标签是用于展示前端页面的具体标签,如<el-tabs>。
本申请实施例可以同时在线预览多个excel文件,其中所述excel文件中可以包含多个sheet页,并可以以多个tab页的形式在页面上展示,而不是将多个sheet页的时候全部显示在一个页面上,便于用户查看excel文件中的数据。
本申请实施例通过预先获取需要预览的excel文件,并对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据,并通过将所述excel文件的内容数据保存至数据库,避免每次都需要对excel文件进行解析,提高了工作效率,节省了计算机资源;同时,在接收文件在线预览请求后,可以直接从数据数库中查找对应内容,简单方便,通过数据库获取数据可以一次性获取多个excel文件,以及获取一个excel文件中的多个sheet页内容,按照预设格式显示,更加清晰简洁,可以提高开发效率。因此本申请实施例可以实现快速、高效的在线预览excel文件的目的。
如图2所示,是本申请在线预览excel文件装置的功能模块图。
本申请所述在线预览excel文件装置100可以安装于电子设备中。根据实现的功能,所述在线预览excel文件装置可以包括文件获取模块101、目标内容解析模块102、数据保存模块103、请求接收模块104和内容显示模块105。本发所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。
在本实施例中,关于各模块/单元的功能如下:
所述文件获取模块101,用于获取需要预览的excel文件。
本申请实施例中所述需要预览的excel文件包括保存在服务器中的excel文件和用户上传的excel文件。
详细地,在获取需要预览的excel文件时,所述文件获取模块101执行下述操作:
当所述需要预览的excel文件为保存在服务器中的excel文件时,获取所述需要预览的excel文件的路径,根据所述路径获取所述需要预览的excel文件;
当所述需要预览的excel文件为用户上传的excel文件时,则通过接收用户上传的excel文件获取所述需要预览的excel文件。
在实际业务系统中,有时用户是在上传excel文件时,需要通过在线预览确定上传文件无误,有时用户是在下载excel文件时,需要确定下载文件无误,因此需要根据两种情况分别获取需要预览的excel文件。
可选地,在获取需要预览的excel文件之前,还包括对所述需要预览的excel文件的类型进行判断,具体包括:通过参数对所述需要预览的excel文件的类型进行判断,当参数中包括excel文件时,确定所述需要预览的excel文件为用户上传的excel文件;否则,确定所述需要预览的excel文件为保存在服务器中的excel文件。其中,所述参数是客户端发送的参数数据。
所述内容解析模块102,用于对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据。
详细地,所述内容解析模块102具体用于:
将所述excel文件转化为二进制字节流;
根据所述excel文件的类型创建对应的对象类;
将所述二进制字节流写入所述对象类中,并根据所述对象类获取所述excel的内容数据。
其中,所述excel文件的类型包括xls文件和xlsx文件,根据所述excel文件的类型的不同需要使用不同的对象类以及不同的方法获取excel内容。所述对象类是java中可以直接操作excel文件类型的对象类,包括用于操作xls文件的HSSFWorkBook和用于操作xlsx文件的XSSFWorkBook。
可选地,在根据所述excel文件的类型创建对应的对象类之前,还包括:确定所述excel文件的类型。所述确定所述excel文件的类型具体包括:获取所述excel文件的文件名;根据所述文件名获取所述excel文件的后缀名;在所述后缀名为xls时,确定所述excel文件为xls文件;在所述后缀名为xlsx时,确定所述excel文件为xlsx文件。
进一步地,在根据所述对象类获取所述excel的内容数据时,所述内容解析模块102具体用于:
利用所述对象类循环遍历所述excel的多个sheet;
设置每个所述sheet页中的单元格样式,并逐行读取每个所述sheet页的内容,得到所述多个sheet对应的多个sheet内容;
将所述多个sheet内容进行汇集,并将预设的分隔符插入每个sheet内容后,得到所述excel的sheet内容;
利用所述对象类获取所述excel的所有sheet名,并在每个sheet名后添加预设的分隔符,得到所述excel的sheet名称;
将所述sheet内容和所述sheet名称汇集得到所述excel的内容数据。
其中,所述预设的分隔符是预设规定的字符串,如“||@@@||”。
本申请实施例在解析excel文件时,将excel文件的多个sheet内容使用分隔符进行保存,有利于后续在前端页面的展示。
所述数据保存模块103,用于将所述excel文件的内容数据保存至数据库中。
可选地,本申请实施例在将所述excel文件的内容数据保存至数据库中之前,还包括:在数据库中创建数据表,所述数据表中包括表名,sheet名称和excel内容的字段。
详细地,本申请实施例将所述excel文件的内容数据保存至数据库中时,所述数据保存模块103具体用于:将所述excel文件内容数据按照预先创建的数据表的字段对应保存至数据库中。
当所述excel文件为多个时,可以循环上述操作,将多个excel文件保存至数据库中,此时,数据库中的一条数据代表一个excel文件以及对应的excel文件内容。
可选地,为保证所述excel文件的内容数据的私密和安全性,所述excel文件的内容数据还可以存储于一区块链的节点中。
本申请实施例通过解析多个excel的多个sheet页内容以及样式,以特定的方式将解析完的内容存储到数据库,使前端页面可以直接从数据库中获取数据,可以提高效率。
所述请求接收模块104,用于接收文件在线预览请求。
详细地,本申请实施例中所述文件在线预览请求是用户在前端页面在对应文件下点击文件在线功能产生的数据请求,所述文件在线预览请求包括用户在上传文件时产生的数据请求和用户在下载文件时产生的数据请求。
进一步地,所述文件在线预览请求中包括文件名称、文件地址等参数。
所述内容显示模块105,用于根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
可选地,本申请实施例通过提前将文件解析内容保存在数据库中,在接收到文件在线预览请求后,可直接从数据库中获取对应的文件内容数据,并以一定格式显示在预先构建的页面上。
本申请实施例中所述页面是客户端的显示页面,用于显示excel文件,可以利用多种前端框架进行构建。
详细地,在根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容数据时,所述内容显示模块105具体执行下述操作:
获取所述文件在线预览请求中的文件名称;
根据所述文件名称在数据库中查找,得到结果数据集;
对所述结果数据集中每条数据,根据预设的分隔符将所述数据中的sheet名称和sheet内容进行切割,得到多个sheet名称数组和对应多个sheet内容数组;
将所述多个sheet名称数组和对应多个sheet内容数组合并,得到excel文件内容数据,并将所述excel文件内容数据返回。
进一步地,在将所述内容数据按照预设的格式显示在预先构建的页面上时,所述内容显示模块105具体执行下述操作:
获取所述excel文件内容数据;
使用双层嵌套循环的预设标签进行布局,渲染页面;
通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上。
详细地,在通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上时,所述内容显示模块105具体用于:
利用外层循环预设标签中每个标签展示所述excel文件内容中一个excel文件对应的excel文件名和excel内容;
利用内层循环预设标签中每个标签展示与当前excel文件对应的sheet名称数组中的每个sheet名称和sheet内容数组中的每个sheet内容。
其中,所述预设标签是用于展示前端页面的具体标签,如<el-tabs>。
本申请实施例可以同时在线预览多个excel文件,其中所述excel文件中可以包含多个sheet页,并可以以多个tab页的形式在页面上展示,而不是将多个sheet页的时候全部显示在一个页面上,便于用户查看excel文件中的数据。
如图3所示,是本申请实现在线预览excel文件方法的电子设备的结构示意图。
所述电子设备1可以包括处理器10、存储器11和总线,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如在线预览excel文件程序12。
其中,所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备1的内部存储单元,例如该电子设备1的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备1的外部存储设备,例如电子设备1上配备的插接式移动硬盘、智能存储卡(Smart Media Card, SMC)、安全数字(Secure Digital, SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备1的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备1的应用软件及各类数据,例如在线预览excel文件程序12的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(Control Unit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如执行在线预览excel文件程序等),以及调用存储在所述存储器11内的数据,以执行电子设备1的各种功能和处理数据。
所述总线可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。所述总线被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。
图3仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图3示出的结构并不构成对所述电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。
例如,尽管未示出,所述电子设备1还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备1还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。
进一步地,所述电子设备1还可以包括网络接口,可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备1与其他电子设备之间建立通信连接。
可选地,该电子设备1还可以包括用户接口,用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备1中处理的信息以及用于显示可视化的用户界面。
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。
所述电子设备1中的所述存储器11存储的在线预览excel文件程序12是多个指令的组合,在所述处理器10中运行时,可以实现:
获取需要预览的excel文件;
对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
将所述excel文件的内容数据保存至数据库中;
接收文件在线预览请求;
根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
进一步地,所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中,所述计算机可读存储介质可以是易失性的,也可以是非易失性的。所述计算机可读存储介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。
所述计算机可读存储介质中存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:
获取需要预览的excel文件;
对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
将所述excel文件的内容数据保存至数据库中;
接收文件在线预览请求;
根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图表记视为限制所涉及的权利要求。
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。

Claims (20)

  1. 一种在线预览excel文件方法,其中,所述方法包括:
    获取需要预览的excel文件;
    对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
    将所述excel文件的内容数据保存至数据库中;
    接收文件在线预览请求;
    根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
  2. 如权利要求1所述的在线预览excel文件方法,其中,所述对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据,包括:
    将所述excel文件转化为二进制字节流;
    根据所述excel文件的类型创建对应的对象类;
    将所述二进制字节流写入所述对象类中,并根据所述对象类获取所述excel的内容数据。
  3. 如权利要求2所述的在线预览excel文件方法,其中,所述根据所述对象类获取所述excel的内容数据,包括:
    利用所述对象类循环遍历所述excel的多个sheet;
    设置每个所述sheet页中的单元格样式,并逐行读取每个所述sheet页的内容,得到所述多个sheet对应的多个sheet内容;
    将所述多个sheet内容进行汇集,并将预设的分隔符插入每个sheet内容后,得到所述excel的sheet内容;
    利用所述对象类获取所述excel的所有sheet名,并在每个sheet名后添加预设的分隔符,得到所述excel的sheet名称;
    将所述sheet内容和所述sheet名称汇集得到所述excel的内容数据。
  4. 如权利要求2所述的在线预览excel文件方法,其中,所述根据所述excel文件的类型创建对应的对象类之前,还包括:
    获取所述excel文件的文件名;
    根据所述文件名获取所述excel文件的后缀名;
    在所述后缀名为xls时,确定所述excel文件为xls文件;
    在所述后缀名为xlsx时,确定所述excel文件为xlsx文件
  5. 如权利要求1至4中任意一项所述的在线预览excel文件方法,其中,所述根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容,包括:
    获取所述文件在线预览请求中的文件名称;
    根据所述文件名称在数据库中查找,得到结果数据集;
    对所述结果数据集中每条数据,根据预设的分隔符将所述数据中的sheet名称和sheet内容进行切割,得到多个sheet名称数组和对应多个sheet内容数组;
    将所述多个sheet名称数组和对应多个sheet内容数组合并,得到excel文件内容数据。
  6. 如权利要求1至4中任意一项所述的在线预览excel文件方法,其中,所述按照预设的格式显示在预先构建的页面上,包括:
    获取所述excel文件内容数据;
    使用双层嵌套循环的预设标签进行布局,渲染页面;
    通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上。
  7. 如权利要求1至4中任意一项所述的在线预览excel文件方法,其中,所述获取需要预览的excel文件,包括:
    当所述需要预览的excel文件为保存在服务器中的excel文件时,获取所述需要预览的excel文件的路径,并根据所述路径获取所述需要预览的excel文件;
    当所述需要预览的excel文件为用户上传的excel文件时,通过接收用户上传的excel文件获取所述需要预览的excel文件。
  8. 一种在线预览excel文件装置,其中,所述装置包括:
    文件获取模块,用于获取需要预览的excel文件;
    内容解析模块,用于对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
    数据保存模块,用于将所述excel文件的内容数据保存至数据库中;
    请求接收模块,用于接收文件在线预览请求;
    内容显示模块,用于根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
  9. 一种电子设备,其中,所述电子设备包括:
    存储器,存储至少一个计算机程序指令;及
    处理器,执行所述存储器中存储的计算机程序指令以执行如下步骤:
    获取需要预览的excel文件;
    对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
    将所述excel文件的内容数据保存至数据库中;
    接收文件在线预览请求;
    根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
  10. 如权利要求9所述的电子设备,其中,所述对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据,包括:
    将所述excel文件转化为二进制字节流;
    根据所述excel文件的类型创建对应的对象类;
    将所述二进制字节流写入所述对象类中,并根据所述对象类获取所述excel的内容数据。
  11. 如权利要求10所述的电子设备,其中,所述根据所述对象类获取所述excel的内容数据,包括:
    利用所述对象类循环遍历所述excel的多个sheet;
    设置每个所述sheet页中的单元格样式,并逐行读取每个所述sheet页的内容,得到所述多个sheet对应的多个sheet内容;
    将所述多个sheet内容进行汇集,并将预设的分隔符插入每个sheet内容后,得到所述excel的sheet内容;
    利用所述对象类获取所述excel的所有sheet名,并在每个sheet名后添加预设的分隔符,得到所述excel的sheet名称;
    将所述sheet内容和所述sheet名称汇集得到所述excel的内容数据。
  12. 如权利要求10所述的电子设备,其中,所述根据所述excel文件的类型创建对应的对象类之前,所述计算机程序指令被处理器执行时还实现如下步骤:
    获取所述excel文件的文件名;
    根据所述文件名获取所述excel文件的后缀名;
    在所述后缀名为xls时,确定所述excel文件为xls文件;
    在所述后缀名为xlsx时,确定所述excel文件为xlsx文件
  13. 如权利要求9至12中任意一项所述的电子设备,其中,所述根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容,包括:
    获取所述文件在线预览请求中的文件名称;
    根据所述文件名称在数据库中查找,得到结果数据集;
    对所述结果数据集中每条数据,根据预设的分隔符将所述数据中的sheet名称和sheet内容进行切割,得到多个sheet名称数组和对应多个sheet内容数组;
    将所述多个sheet名称数组和对应多个sheet内容数组合并,得到excel文件内容数据。
  14. 如权利要求9至12中任意一项所述的电子设备,其中,所述按照预设的格式显示在预先构建的页面上,包括:
    获取所述excel文件内容数据;
    使用双层嵌套循环的预设标签进行布局,渲染页面;
    通过所述双层嵌套循环的预设标签将所述excel文件内容数据对应显示在预先构建的页面上。
  15. 如权利要求9至12中任意一项所述的电子设备,其中,所述获取需要预览的excel文件,包括:
    当所述需要预览的excel文件为保存在服务器中的excel文件时,获取所述需要预览的excel文件的路径,并根据所述路径获取所述需要预览的excel文件;
    当所述需要预览的excel文件为用户上传的excel文件时,通过接收用户上传的excel文件获取所述需要预览的excel文件。
  16. 一种计算机可读存储介质,存储有计算机程序,其中,所述计算机程序被处理器执行时实现如下步骤:
    获取需要预览的excel文件;
    对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据;
    将所述excel文件的内容数据保存至数据库中;
    接收文件在线预览请求;
    根据所述文件在线预览请求在数据库中查找得到对应的excel文件的内容数据,并将所述内容数据按照预设的格式显示在预先构建的页面上。
  17. 如权利要求16所述的计算机可读存储介质,其中,所述对所述excel文件进行内容解析,得到与所述excel文件对应的内容数据,包括:
    将所述excel文件转化为二进制字节流;
    根据所述excel文件的类型创建对应的对象类;
    将所述二进制字节流写入所述对象类中,并根据所述对象类获取所述excel的内容数据。
  18. 如权利要求17所述的计算机可读存储介质,其中,所述根据所述对象类获取所述excel的内容数据,包括:
    利用所述对象类循环遍历所述excel的多个sheet;
    设置每个所述sheet页中的单元格样式,并逐行读取每个所述sheet页的内容,得到所述多个sheet对应的多个sheet内容;
    将所述多个sheet内容进行汇集,并将预设的分隔符插入每个sheet内容后,得到所述excel的sheet内容;
    利用所述对象类获取所述excel的所有sheet名,并在每个sheet名后添加预设的分隔符,得到所述excel的sheet名称;
    将所述sheet内容和所述sheet名称汇集得到所述excel的内容数据。
  19. 如权利要求17所述的计算机可读存储介质,其中,所述根据所述excel文件的类型创建对应的对象类之前,所述计算机程序被处理器执行时还实现如下步骤:
    获取所述excel文件的文件名;
    根据所述文件名获取所述excel文件的后缀名;
    在所述后缀名为xls时,确定所述excel文件为xls文件;
    在所述后缀名为xlsx时,确定所述excel文件为xlsx文件
  20. 如权利要求16至19中任意一项所述的计算机可读存储介质,其中,所述根据所述文件在线预览请求在数据库中查找得到对应的excel文件内容,包括:
    获取所述文件在线预览请求中的文件名称;
    根据所述文件名称在数据库中查找,得到结果数据集;
    对所述结果数据集中每条数据,根据预设的分隔符将所述数据中的sheet名称和sheet内容进行切割,得到多个sheet名称数组和对应多个sheet内容数组;
    将所述多个sheet名称数组和对应多个sheet内容数组合并,得到excel文件内容数据。
PCT/CN2021/123177 2020-11-19 2021-10-12 在线预览excel文件方法、装置、电子设备及存储介质 WO2022105478A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011302184.9 2020-11-19
CN202011302184.9A CN112347737A (zh) 2020-11-19 2020-11-19 在线预览excel文件方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2022105478A1 true WO2022105478A1 (zh) 2022-05-27

Family

ID=74364412

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/123177 WO2022105478A1 (zh) 2020-11-19 2021-10-12 在线预览excel文件方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN112347737A (zh)
WO (1) WO2022105478A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112347737A (zh) * 2020-11-19 2021-02-09 深圳壹账通智能科技有限公司 在线预览excel文件方法、装置、电子设备及存储介质
CN112861486A (zh) * 2021-04-25 2021-05-28 成都淞幸科技有限责任公司 半结构化文件的数据集成方法、装置、设备及存储介质
CN117787251B (zh) * 2024-02-28 2024-05-07 江苏中威科技软件系统有限公司 多格式文件组合或合并阅读展开excel隐藏内容的方法

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220500A1 (en) * 2014-02-06 2015-08-06 Vojin Katic Generating preview data for online content
US20150220499A1 (en) * 2014-02-06 2015-08-06 Vojin Katic Generating preview data for online content
CN107241227A (zh) * 2017-06-29 2017-10-10 济南浪潮高新科技投资发展有限公司 一种网络数据报表的配置及生成方法
CN110688595A (zh) * 2019-09-09 2020-01-14 上海凯京信达科技集团有限公司 一种文件在线预览方法、装置、设备和存储介质
CN110990345A (zh) * 2019-11-28 2020-04-10 中国银行股份有限公司 一种Excel文件在线预览的方法及装置
CN111833981A (zh) * 2020-04-30 2020-10-27 宁波市科技园区明天医网科技有限公司 结构化报告制作编写方法
CN112347737A (zh) * 2020-11-19 2021-02-09 深圳壹账通智能科技有限公司 在线预览excel文件方法、装置、电子设备及存储介质

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220500A1 (en) * 2014-02-06 2015-08-06 Vojin Katic Generating preview data for online content
US20150220499A1 (en) * 2014-02-06 2015-08-06 Vojin Katic Generating preview data for online content
CN107241227A (zh) * 2017-06-29 2017-10-10 济南浪潮高新科技投资发展有限公司 一种网络数据报表的配置及生成方法
CN110688595A (zh) * 2019-09-09 2020-01-14 上海凯京信达科技集团有限公司 一种文件在线预览方法、装置、设备和存储介质
CN110990345A (zh) * 2019-11-28 2020-04-10 中国银行股份有限公司 一种Excel文件在线预览的方法及装置
CN111833981A (zh) * 2020-04-30 2020-10-27 宁波市科技园区明天医网科技有限公司 结构化报告制作编写方法
CN112347737A (zh) * 2020-11-19 2021-02-09 深圳壹账通智能科技有限公司 在线预览excel文件方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN112347737A (zh) 2021-02-09

Similar Documents

Publication Publication Date Title
WO2022105478A1 (zh) 在线预览excel文件方法、装置、电子设备及存储介质
US11461111B2 (en) Method for running applets, and electronic device
Buels et al. JBrowse: a dynamic web platform for genome visualization and analysis
JP6922538B2 (ja) Api学習
CN111813963B (zh) 知识图谱构建方法、装置、电子设备及存储介质
US9015657B2 (en) Systems and methods for developing and delivering platform adaptive web and native application content
US20160371238A1 (en) Computing device and method for converting unstructured data to structured data
US20150178292A1 (en) Methods and systems for data serialization and deserialization
RU2595524C2 (ru) Устройство и способ обработки содержимого веб-ресурса в браузере
CN1573749A (zh) 使用外部计划主题的Web网页绘制机制
US9141344B2 (en) Hover help support for application source code
US7865481B2 (en) Changing documents to include changes made to schemas
US9514184B2 (en) Systems and methods for a high speed query infrastructure
WO2022100032A1 (zh) 系统分析可视化方法、装置、电子设备及计算机可读存储介质
CN111753140A (zh) Xml文件解析方法及相关设备
CN109710224B (zh) 页面处理方法、装置、设备及存储介质
CN112486490B (zh) 前端代码打包方法、装置、电子设备及存储介质
CN115048111B (zh) 基于元数据的代码生成方法、装置、设备及介质
CN110851136A (zh) 数据获取方法、装置、电子设备及存储介质
CN115280283A (zh) 在kubernets中运行pbs作业
US9971751B1 (en) Version-specific request processing
US10180931B2 (en) Using a template processor to determine context nodes
US9111009B2 (en) Self-parsing XML documents to improve XML processing
EP4095713A1 (en) Systems and methods for generating a target dataset having a target data format on a user device
CN107643892B (zh) 接口处理方法、装置、存储介质和处理器

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21893627

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 220823)

122 Ep: pct application non-entry in european phase

Ref document number: 21893627

Country of ref document: EP

Kind code of ref document: A1