File parsing method, device, electronic device and storage medium

By determining the file type and directory logic of the target Office file, parsing the file attributes and content, and recursively obtaining nested files, the problems of incomplete nested file parsing and format incompatibility in the existing technology are solved, and efficient cross-platform file parsing is achieved.

CN114398309BActive Publication Date: 2025-09-16HEFEI SHANJIE INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111476492.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2025-09-16
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

Existing platforms such as Microsoft Windows API interface, NET NPOI library or Java POI class library have problems such as incomplete nested file parsing, incompatible file formats and poor parsing efficiency when parsing Office nested files.

Method used

A file parsing method is provided. By determining the file type of the target Office file, the file directory is parsed according to the corresponding file directory logic, the file attribute information and content are output, and when nested files exist, the nested files are recursively traversed to obtain them until the parsing of multi-layer nested files is completed.

Benefits of technology

It achieves cross-platform Office nested file parsing with strong compatibility for multiple file formats and comprehensive parsing content, avoiding omissions or errors in nested file parsing and improving parsing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398309B_ABST
    Figure CN114398309B_ABST
Patent Text Reader

Abstract

The present application provides a file parsing method, apparatus, electronic device, and storage medium, including: (A) determining a target Office file, where the target Office file is an Office file operated in real time on a terminal device; (B) determining a target file type of an Office file to be parsed at a current layer; (C) obtaining a file directory of the Office file to be parsed according to a file directory parsing logic corresponding to the target file type; (D) outputting file attribute information and file content of the Office file to be parsed based on the file directory; (E) determining whether there is a nested file in the Office file to be parsed based on the file directory; and (F) if there is a nested file in the Office file to be parsed, obtaining the nested file and treating the nested file as the Office file to be parsed, so as to return to execution of step (B).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of file parsing technology, and more specifically, to a file parsing method, device, electronic device, and storage medium. Background Art

[0002] Mainstream providers of Office nested file suites include Microsoft Office, Kingsoft WPS Office, and Yongzhong Office, as well as open source software such as Open Office and Libre Office. These file formats can be categorized as OLE, ODF, and OOXML, and the file formats differ between versions. Existing platforms such as Microsoft Windows APIs, .NET NPOI libraries, or Java POI libraries often encounter issues with incomplete nested file parsing, file format incompatibility, and poor parsing efficiency when parsing files. Therefore, a cross-platform Office nested file parsing method with strong compatibility and comprehensive parsing content is needed. Summary of the Invention

[0003] In view of this, the purpose of this application is to provide a file parsing method, device, electronic device and storage medium, which can comprehensively parse Office nested files in various file formats through a single platform.

[0004] In a first aspect, an embodiment of the present application provides a file parsing method, including: (A) determining a target Office file, where the target Office file is an Office file operated in real time on a terminal device; (B) determining a target file type of the Office file to be parsed in the current layer; (C) obtaining a file directory of the Office file to be parsed according to a file directory parsing logic corresponding to the target file type; (D) outputting file attribute information and file content of the Office file to be parsed based on the file directory; (E) determining whether there is a nested file in the Office file to be parsed based on the file directory; (F) if there is a nested file in the Office file to be parsed, obtaining the nested file and treating the nested file as the Office file to be parsed to return to execution step (B).

[0005] Preferably, there are multiple nested files, wherein step (F) includes: (F1) if it is determined that there are multiple nested files in the Office file to be parsed, traverse the multiple nested files and determine whether i is equal to m, where m is the number of nested files in the Office file to be parsed in the current layer, and the initial value of i is zero; (F2) if i is not equal to m, make i=i+1, and take the i-th nested file as the Office file to be parsed in the current layer, and return to execute step (B); (F3) if i is equal to m, then complete the parsing of the Office file to be parsed.

[0006] Preferably, the target file type of the Office file to be parsed is determined in the following manner: determining the file signature of the Office file to be parsed, and determining the target file type of the Office file to be parsed based on the file signature; and / or determining the file extension of the Office file to be parsed, and determining the target file type of the Office file to be parsed based on the file extension; and / or determining the data structure of the file directory of the Office file to be parsed, and determining the target file type of the Office file to be parsed based on the data structure.

[0007] Preferably, when step (B) is executed for the first time, the Office file to be parsed in the current layer is the target Office file itself; when step (B) is not executed for the first time, the Office file to be parsed in the current layer is a nested file.

[0008] Preferably, the method further comprises:

[0009] The file content and / or file attributes determined in the Office file to be parsed are converted into a parsed file corresponding to the target Office file, wherein the file content includes at least one or more of text, pictures, audio and video, compressed packages and nested files. For the text in the file content, the text is converted into a text file in txt format; for the pictures, audio and video or compressed packages in the file content, the corresponding pictures, audio and video or compressed packages are output according to the original format of the file content; for the nested files in the file content, the Office files in the corresponding document format are output according to the file extension of the nested files; for the icons of the nested files in the file content, the icons of the nested files are converted into image files in emf format.

[0010] Preferably, the method further includes: determining the file version of the Office file to be parsed based on the file extension or the data structure of the file directory of the Office file to be parsed; when it is determined that the file version of the Office file to be parsed is the first version, displaying the file directory of the Office file to be parsed in the form of a list entry; when it is determined that the text version of the Office file to be parsed is the second version, displaying the file directory of the Office file to be parsed in the form of a structure tree, and the version level of the first version is higher than the version level of the second version.

[0011] Preferably, step (E) includes: (E1) determining whether the preset path in the file directory includes nested file data; (E2) if so, determining that there are nested files in the Office file to be parsed; (E3) if not, determining that there are no nested files in the Office file to be parsed; wherein, the Office file to be parsed includes at least one of the following items: Word file, Excel file, PowerPoint file, and for the first version of the Office file to be parsed, the preset path includes at least one of the following items: storing nested files of Word files in the word / media and word / embeddings folders of the file directory; storing nested files of Excel files in the xl / media and xl / embeddings folders of the file directory; storing nested files of PowerPoint files in the ppt / media and ppt / embeddings folders of the file directory; for the second version of the Office file to be parsed, the preset path includes at least one of the following items: mounting nested files of Word files under the ObjectPool of the file directory; mounting nested files of Excel files under the MBD of the file directory; storing nested files of PowerPoint files in the PowerPoint Document data stream of the file directory.

[0012] In a second aspect, an embodiment of the present application further provides a file parsing device, comprising:

[0013] A determination module is used to determine a target Office file, where the target Office file is an Office file that is operated on a terminal device in real time;

[0014] A detection module is used to determine the target file type of the Office file to be parsed at the current layer;

[0015] A generation module is used to obtain the file directory of the Office file to be parsed according to the file directory parsing logic corresponding to the target file type;

[0016] The output module is used to output the file attribute information and file content of the Office file to be parsed according to the file directory;

[0017] A judgment module is used to determine whether there are nested files in the Office file to be parsed according to the file directory;

[0018] The nesting module is used to obtain the nested file if there is a nested file in the Office file to be parsed, and use the nested file as the Office file to be parsed, so that the detection module can continue to determine the target file type of the Office file to be parsed.

[0019] In a third aspect, an embodiment of the present application also provides an electronic device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the above file parsing method.

[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the above file parsing method are executed.

[0021] The embodiments of the present application provide a file parsing method, device, electronic device and storage medium, which first determines that the target Office file is the Office file to be parsed in the current layer, determines the target file type of the Office file to be parsed in the current layer, obtains the file directory of the Office file to be parsed according to the file directory parsing logic corresponding to the target file type, outputs the file attribute information and file content of the Office file to be parsed according to the file directory, and determines whether there are nested files in the Office file to be parsed according to the file directory. If there are nested files in the Office file to be parsed, the nested files are obtained and used as the Office file to be parsed, thereby achieving traversal parsing of the target Office file when there are multiple layers of nested files in the target Office file, avoiding omissions or parsing errors in the parsing of nested files during the parsing process, and making the parsing content comprehensive and compatible with Office files of multiple file formats.

[0022] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 A flowchart of the file parsing method provided in an embodiment of the present application;

[0025] Figure 2 A schematic diagram of a target Office file provided in an embodiment of the present application;

[0026] Figure 3 The basis provided by the embodiments of this application Figure 2 Schematic diagram of some file directories parsed from the Office files to be parsed;

[0027] Figure 4 A flowchart of the parsing steps for nested files provided in an embodiment of the present application;

[0028] Figure 5 A flowchart of the steps for obtaining nested files provided in an embodiment of the present application;

[0029] Figure 6 A schematic diagram of the structure of a file parsing device provided in an embodiment of the present application;

[0030] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of illustration and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowcharts can be implemented out of sequence, and steps without logical context can be reversed or implemented simultaneously. In addition, those skilled in the art, under the guidance of the contents of this application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.

[0032] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0033] In the prior art, mainstream Office nested file suite providers on the market include Microsoft Office, Kingsoft WPS Office, Yongzhong Office, etc., and there are also some open source software such as Open Office and Libre Office. The above file format types can be classified into three categories: OLE, ODF and OOXML, and the file formats of different versions are also different. When existing platforms such as Microsoft Windows API interfaces, NET NPOI libraries or Java POI class libraries parse files, there are usually problems such as incomplete parsing of nested files, incompatible file formats and poor parsing efficiency. Therefore, a cross-platform Office nested file content parsing method with strong compatibility and comprehensive parsing content is needed.

[0034] In response to the above problems, embodiments of the present application provide a file parsing method, device, electronic device, and storage medium, which are described below through embodiments.

[0035] To facilitate understanding of the present application, the technical solutions provided in the present application are described in detail below in conjunction with specific embodiments.

[0036] See also Figure 1 , is a file parsing method provided in an embodiment of the present application, the method comprising:

[0037] (A) Determine the target Office file.

[0038] The target Office file can be an Office file that the user is operating on in real time on the terminal device, specifically, an opened, moved, or edited Office file. It can also be a file sent by a monitoring system. The monitoring system can perform real-time detection of files with preset paths and / or types on the terminal device based on a user-defined monitoring directory. If a corresponding Office file is detected, it can be sent to the parsing engine, which then executes the file parsing method of this embodiment.

[0039] (B) Determine the target file type of the Office file to be parsed at the current layer.

[0040] The target file type of the Office file to be parsed can be one of the following: ODF OOXML, ODFXML, OLE, XLSB, or RTF. Specifically, the target file type can be determined by determining the file signature of the Office file to be parsed and based on the signature; and / or by determining the file extension of the Office file to be parsed and based on the file extension.

[0041] The file signature here can be obtained by converting the Office file into a binary format file, wherein the file signature is determined by the first few bits of the file header of the binary format file, and then the target file type of the Office file to be parsed is determined by comparing the file signature with the file signature corresponding to the target file type.

[0042] The file extension here can usually be identified by the suffix of the file name. For example, the suffix .doc is a low-version Word file, and its target file type is OLE type. The suffix .docx is a high-version Word file, and its target file type is ODF OOXML type.

[0043] (C) Obtain the file directory of the Office file to be parsed according to the file directory parsing logic corresponding to the target file type.

[0044] Here, the file version of the Office file to be parsed may be determined according to the file extension of the Office file to be parsed, and the data structure of the file directory of the Office file to be parsed may be determined based on the file version of the Office file to be parsed.

[0045] For example, when the file version of the Office file to be parsed is determined to be version 1, the file directory of the Office file to be parsed is displayed as a list item. When the text version of the Office file to be parsed is determined to be version 2, the file directory of the Office file to be parsed is displayed as a structure tree, with the version level of version 1 being higher than the version level of version 2. For example, taking Microsoft Office files as an example, version 1 may refer to versions after Microsoft Office 2007, i.e., higher-version Office files, and version 2 may refer to versions before Microsoft Office 2007, i.e., lower-version Office files.

[0046] Specifically, such as Figure 2As shown, a schematic diagram of the nested structure of a target Office file is provided.

[0047] In this example, the target Office file is a first-level high-version Word file, in which are nested the second-level high-version Word file, the second-level high-version Excel file, the second-level high-version Power Point file, the second-level low-version Word file, the second-level low-version Excel file, the second-level low-version Power Point file, and the third-level nested file, i.e., the nested files included in each second-level nested file. Figure 2 The Office file to be parsed shown in the following example can be generated: Figure 3 The basis shown Figure 2 Part of the file directory parsed from the Office files to be parsed.

[0048] (D) Output the file attribute information and file content of the Office file to be parsed according to the file directory.

[0049] File attributes refer to information such as the document creation time, title, subject, and author. File content refers to the text, images, audio, and nested files contained within the file. Nested files in the first-level Office file are typically displayed as icons in the first-level file preview.

[0050] Specifically, the file attribute information and file content of the Office file to be parsed are searched in the specified path of the file directory. For example, Figure 2As shown, the nested high-version Word file property information is stored in the docProps / core.xml and docProps / app.xml files, and the file content is stored in the word / document.xml file and the word / media folder; the nested high-version Excel file property information is stored in the docProps / core.xml and docProps / app.xml files, and the file content is stored in the xl / workbook.xml file, the xl / sharedStrings.xml file, the xl / worksheets / sheet, and the xl / media folder; the nested high-version PowerPoint file property information is stored in the docProps / core.xml and docProps / app.xml files, and the file content is stored in the ppt / presentation.xml file, the ppt / slides, and the ppt / media folder. The property information of nested lower-version Word files is stored in the Summary Information and Document Summary Information data streams, and the file content is stored in the Word Document and Data data streams; the property information of nested lower-version Excel files is stored in the SummaryInformation and Document Summary Information data streams, and the file content is stored in the Work Book data stream; the property information of nested lower-version PowerPoint files is stored in the Summary Information and DocumentSummary Information data streams, and the file content is stored in the Pictures and PowerPoint Document data streams.

[0051] After finding the corresponding file attribute information and file content according to the above path, output the file attribute information and file content. Here, for the file content and / or file attributes determined in the to-be-analyzed Office file, output the analyzed file. The file content here includes at least one or more of text, pictures, audio / video, compressed packages, and nested files. Exemplarily, for the text in the file content, the text can be converted into a text file in txt format; for the pictures, audio / video, or compressed packages in the file content, output the corresponding pictures, audio / video, or compressed packages according to the original format of the file content. For example, if the file content includes a picture file in jpg format, output this picture file in jpg format. For the nested files in the file content, output them as Office files in the corresponding document format according to the file extension of the nested files, and for the icons of the nested files in the file content, convert the icons of the nested files into picture files in emf format. The document format here can be Word, Excel, PowerPoint, etc. For example, if the to-be-analyzed Office file includes a Word 2003 document, output this Word 2003 document in Word format and output the icon of this Word 2003 document in emf format.

[0052] Furthermore, when outputting the file attribute information and file content of the to-be-analyzed Office file, the files can be classified by means of coded naming. Among them, the first-segment codes in the file names in the same layer are the same, and the second-segment codes in the file names of the same format are the same. For example, the text in the high-version word files in the first layer is converted into a txt format file, and the name is 01-01-WORD-Text.txt. The text in the low-version word files in the second layer is converted into a txt format file, and the name is 02-01-word-Text.txt. Among them, the first-segment code "01" refers to that this file is a file in the first layer, that is, the target Office file, and "02" refers to the nested file in the target Office file, that is, the file in the second layer; the second-segment code "01" can refer to that this file is the first file parsed from the files in this layer; the third-segment code "WORD" can refer to that this file is parsed from the high-version word files, and "word" can refer to that this file is parsed from the low-version word files; the fourth-segment code "Text" can refer to that this file is the analysis of the text in the high-version word files in the first layer. Thus, it can be clearly known from the output file name and file format which layer of the target Office file the file is parsed from and the corresponding content parsed.

[0053] (E) Determine whether there are nested files in the to-be-analyzed Office file according to the file directory.

[0054] (F) If there is a nested file in the Office file to be parsed, the nested file is obtained and used as the Office file to be parsed, so as to return to step (B).

[0055] Here, the file directory is used to determine whether there is a nested file in the Office file to be parsed. If so, the corresponding nested file is obtained, and the nested file is returned to step (B) as the Office file to be parsed for traversal. If it is determined that there is no nested file in the Office file to be parsed, the traversal ends.

[0056] An embodiment of the present application provides a file parsing method, which first determines that a target Office file is an Office file to be parsed in the current layer, determines the target file type of the Office file to be parsed in the current layer, obtains the file directory of the Office file to be parsed according to the file directory parsing logic corresponding to the target file type, outputs the file attribute information and file content of the Office file to be parsed according to the file directory, determines whether there are nested files in the Office file to be parsed according to the file directory, and if there are nested files in the Office file to be parsed, obtains the nested files and uses the nested files as the Office file to be parsed, thereby achieving traversal parsing of the target Office file when there are multiple layers of nested files in the target Office file, avoiding omissions or errors in the nested file parsing process, and comprehensively parsing the content while being compatible with Office files of multiple file formats.

[0057] See also Figure 4 , which is a nested file parsing step provided in an embodiment of the present application, is applicable when step (E) is initially executed to determine that the current layer of Office files to be parsed includes multiple nested files. This step includes:

[0058] (F1) If it is determined that there are multiple nested files in the Office file to be parsed, traverse the multiple nested files and determine whether i is equal to m, where m is the number of nested files in the Office file to be parsed at the current level, and the initial value of i is zero;

[0059] (F2) If i is not equal to m, set i=i+1, and use the i-th nested file as the Office file to be parsed in the current layer, and return to step (B);

[0060] (F3) If i is equal to m, the parsing of the Office file to be parsed is completed.

[0061] Here, the initial value of i is 0. In step F1, the first nested file among the multiple nested files is first used as the office file to be parsed in the current layer, and steps B to E are performed on the first nested file. At this time, if the first nested file also includes nested files, steps B to E are performed on the nested files in the first nested file. If the first nested file does not include nested files, it is determined whether the multiple nested files have been traversed (that is, whether i is equal to m). If not, i=i+1, and steps B to E are performed on the second nested file in the multiple nested files. This continues until all nested files in the Office file to be parsed in the current layer are traversed and parsed. At this point, all file contents and file attribute information in the target Office file have been traversed and parsed, avoiding the omission of a certain layer or a certain nested file in the nested file.

[0062] See also Figure 5 , which is a step of obtaining a nested file provided in an embodiment of the present application, and includes:

[0063] (E1) determining whether a preset path in a file directory includes nested file data;

[0064] (E2) If yes, then determine that there is a nested file in the Office file to be parsed;

[0065] (E3) If not, it is determined that there is no nested file in the Office file to be parsed.

[0066] The Office file to be parsed includes at least one of the following items: a Word file, an Excel file, and a PowerPoint file.

[0067] For the first version of the Office file to be parsed, the preset path includes at least one of the following items: storing nested files of Word files in the word / media and word / embeddings folders of the file directory; storing nested files of Excel files in the xl / media and xl / embeddings folders of the file directory; storing nested files of PowerPoint files in the ppt / media and ppt / embeddings folders of the file directory.

[0068] For the second version of the Office file to be parsed, the preset path includes at least one of the following items: mounting the nested files of the Word file under the ObjectPool of the file directory; mounting the nested files of the Excel file under the MBD of the file directory; storing the nested files of the PowerPoint file in the PowerPoint Document data stream of the file directory. Specific embodiments

[0070] A cross-platform Office nested file content parsing method is provided, which is executed by a parsing engine and includes:

[0071] S1: Monitoring system Hook leaks office documents;

[0072] S2: The parsing engine loads the file to be parsed;

[0073] S3: The parsing engine parses the file type. If it is ODF OOXML, go to S4-1; if it is ODFXML, go to S4-2; if it is OLE, go to S4-3; if it is XLSB, go to S4-4; if it is RTF, go to S4-5;

[0074] S4-1: Parse ODF OOXML file directory;

[0075] S4-2: Parsing ODFXML file directory;

[0076] S4-3: Parsing OLE file directory;

[0077] S4-4: Parsing XLSB file directory;

[0078] S4-5: Parsing RTF file directory;

[0079] S5: parse the file attribute information according to the file directory;

[0080] S6: Parse the file content according to the file directory;

[0081] S7: Determine whether the current file contains nested files. If so, go to S8; if not, go to S9.

[0082] S8: Get the nested file entry address;

[0083] S9: Parse the nested file content layer by layer through S2-S8. Once all nested files are completely parsed, the entire file is parsed.

[0084] Among them, when executing step S3, the parsing engine comprehensively determines the file type based on the file signature and file extension. If it is ODF OOXML type, go to S4-1; if it is ODFXML type, go to S4-2; if it is OLE type, go to S4-3; if it is XLSB type, go to S4-4; if it is RTF type, go to S4-5.

[0085] When executing step S7, the parsing engine determines whether the current file contains nested files through the file directory. If it does, go to S8; if not, go to S9;

[0086] When executing step S8, the parsing engine sequentially traverses the lower-level nested files of the current file, obtains the nested file entry address, and then goes to S2 for subsequent nested disassembly layer by layer;

[0087] The platform described in this application not only supports content parsing of file text, pictures, audio and video, compressed packages, file attributes, etc., but also supports nested file parsing, specifically including multi-layer nesting of low-version Office files in low-version Office files, multi-layer nesting of low-version Office files in high-version Office files, multi-layer nesting of high-version Office files in high-version Office files, and multi-layer nesting of high-version Office files in low-version Office files, with full content parsing; the platform described in this application is compatible with mainstream Office nested file suites at home and abroad, such as Microsoft Office, WPS Office, Yongzhong Office, Libre Office, Open Office and other daily office files, with strong compatibility; the platform described in this application provides a cross-platform file content parsing method, which is compatible with Windows, Linux, MacOS, domestic operating systems and other systems, and has a wide deployment range; the platform described in this application does not rely on third-party plug-ins, and directly uses C++ language to parse office file directories and extract content from them, with a fast parsing speed.

[0088] Based on the same inventive concept, the embodiment of the present application also provides a file parsing device corresponding to the file parsing method. Since the principle of solving the problem by the file parsing device in the embodiment of the present application is similar to the above-mentioned file parsing method in the embodiment of the present application, the implementation of the file parsing device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0089] See also Figure 6 , Figure 6 This is a schematic diagram of the structure of a file parsing device provided in an embodiment of the present application. Figure 6 As shown in , the file parsing device 600 includes:

[0090] A determination module 610 is used to determine a target Office file;

[0091] A detection module 620 is used to determine the target file type of the Office file to be parsed at the current layer;

[0092] A generating module 630 is configured to obtain a file directory of the Office file to be parsed according to a file directory parsing logic corresponding to the target file type;

[0093] Output module 640, used to output file attribute information and file content of the Office file to be parsed according to the file directory;

[0094] A determination module 650 is used to determine whether there is a nested file in the Office file to be parsed according to the file directory;

[0095] The nesting module 660 is configured to obtain the nested file if there is a nested file in the Office file to be parsed, and use the nested file as the Office file to be parsed, so that the detection module can continue to determine the target file type of the Office file to be parsed.

[0096] In a preferred embodiment, the nested files include multiple ones, wherein the third judgment module 660 is further used to: (F1) if it is determined that there are multiple nested files in the Office file to be parsed, traverse the multiple nested files and determine whether i is equal to m, where m is the number of nested files in the Office file to be parsed in the current layer, and the initial value of i is zero; (F2) if i is not equal to m, make i=i+1, and take the i-th nested file as the Office file to be parsed in the current layer, and return to execute step (B); (F3) if i is equal to m, then complete the parsing of the Office file to be parsed.

[0097] In a preferred embodiment, the detection module 620 determines the target file type of the Office file to be parsed by: determining the file signature of the Office file to be parsed, and determining the target file type of the Office file to be parsed based on the file signature; and / or determining the file extension of the Office file to be parsed, and determining the target file type of the Office file to be parsed based on the file extension.

[0098] In a preferred embodiment, when the detection module 620 is executed for the first time, the Office file to be parsed in the current layer is the target Office file itself; when it is not executed for the first time, the Office file to be parsed in the current layer is a nested file.

[0099] In a preferred embodiment, the output module 640 is also used to: convert the file content and / or file attributes determined in the Office file to be parsed into a parsed file, wherein the file content includes at least one or more of text, pictures, audio and video, compressed packages and nested files; for the text in the file content, convert the text into a text file in txt format; for the pictures, audio and video, and compressed packages in the file content, output the corresponding pictures, audio and video or compressed packages according to the original format of the file content; for the nested files in the file content, output the Office files in the corresponding document format according to the file extension of the nested files; for the icons of the nested files in the file content, convert the icons of the nested files into image files in emf format.

[0100] In a preferred embodiment, the detection module 620 is further used to: determine the file version of the Office file to be parsed based on the file extension or the data structure of the file directory of the Office file to be parsed; when it is determined that the file version of the Office file to be parsed is the first version, display the file directory of the Office file to be parsed in the form of a list entry; when it is determined that the text version of the Office file to be parsed is the second version, display the file directory of the Office file to be parsed in the form of a structure tree, and the version level of the first version is higher than the version level of the second version.

[0101] In a preferred embodiment, the judgment module 650 is specifically used to: determine whether the preset path in the file directory includes nested file data; if so, determine that there is a nested file in the Office file to be parsed; if not, determine that there is no nested file in the Office file to be parsed; wherein, the Office file to be parsed includes at least one of the following items: Word file, Excel file, PowerPoint file, for the first version of the Office file to be parsed, the preset path includes at least one of the following items: storing nested files of Word files in the word / media and word / embeddings folders of the file directory; storing nested files of Excel files in the xl / media and xl / embeddings folders of the file directory; storing nested files of PowerPoint files in the ppt / media and ppt / embeddings folders of the file directory; for the second version of the Office file to be parsed, the preset path includes at least one of the following items: mounting nested files of Word files under the ObjectPool of the file directory; mounting nested files of Excel files under the MBD of the file directory; storing nested files of PowerPoint files in the PowerPoint Document data stream of the file directory.

[0102] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown in FIG, electronic device 700 includes a processor 710, a memory 720, and a bus 730.

[0103] The memory 720 stores machine-readable instructions executable by the processor 710. When the electronic device 700 is running, the processor 710 communicates with the memory 720 via the bus 730. When the machine-readable instructions are executed by the processor 710, the above-mentioned Figure 1 The steps of the file parsing method in the illustrated method embodiment and the specific implementation thereof can be found in the method embodiment, which will not be described in detail here.

[0104] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 The steps of the file parsing method in the illustrated method embodiment and the specific implementation thereof can be found in the method embodiment, which will not be described in detail here.

[0105] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0106] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0107] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0108] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0109] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable memory that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0110] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-mentioned embodiments within the technical scope disclosed in the present application, or perform equivalent replacements for some of the technical features thereof. These modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A file parsing method, characterized in that: include: (A) Determine the target Office file; (B) Determine the target file type and file version of the Office file to be parsed at the current layer; (C) obtaining a file directory corresponding to the file version of the Office file to be parsed according to the file directory parsing logic corresponding to the target file type; (D) outputting file attribute information and file content of the Office file to be parsed according to the file directory, and converting the file content and / or file attributes of the Office file to be parsed into a parsed file corresponding to the target Office file, wherein the file content includes at least one or more of text, pictures, audio and video, compressed packages, and nested files; for text in the file content, converting the text into a text file in txt format; for pictures, audio and video, or compressed packages in the file content, outputting the corresponding pictures, audio and video, or compressed packages according to the original format of the file content; for nested files in the file content, outputting Office files in corresponding document formats according to the file extensions of the nested files; for icons of nested files in the file content, converting the icons of the nested files into image files in emf format; (E) determining, based on the file directory, whether there is a nested file in the Office file to be parsed; (F) If there is a nested file in the Office file to be parsed, the nested file is obtained and used as the Office file to be parsed, so as to return to step (B); the nested file includes multiple files, wherein step (F) includes: (F1) If it is determined that there are multiple nested files in the Office file to be parsed, traverse the multiple nested files and determine whether i is equal to m, where m is the number of nested files in the Office file to be parsed at the current level and the initial value of i is zero; (F2) If i is not equal to m, set i=i+1, and use the i-th nested file as the Office file to be parsed in the current layer, and return to step (B); (F3) If i is equal to m, the parsing of the Office file to be parsed is completed.

2. The method according to claim 1, characterized in that Determine the target file type of the Office file to be parsed using the following methods: Determine the file signature of the Office file to be parsed, and determine the target file type of the Office file to be parsed based on the file signature; and / or Determine the file extension of the Office file to be parsed, and determine the target file type of the Office file to be parsed based on the file extension; and / or The data structure of the file directory of the Office file to be parsed is determined, and the target file type of the Office file to be parsed is determined according to the data structure.

3. The method according to claim 1, characterized in that When step (B) is first executed, the Office file to be parsed at the current layer is the target Office file itself. When step (B) is not executed for the first time, the Office file to be parsed at the current layer is a nested file.

4. The method according to claim 2, characterized in that Also includes: Determine the file version of the Office file to be parsed based on the file extension or file directory data structure of the Office file to be parsed; When it is determined that the file version of the Office file to be parsed is the first version, the file directory of the Office file to be parsed is displayed in the form of a list item; When it is determined that the text version of the Office file to be parsed is the second version, the file directory of the Office file to be parsed is displayed in a structure tree format, and the version level of the first version is higher than the version level of the second version.

5. The method according to claim 4, characterized in that Step (E) comprises: (E1) determining whether a preset path in the file directory includes nested file data; (E2) If yes, determining whether there is a nested file in the Office file to be parsed; (E3) If not, determining that there is no nested file in the Office file to be parsed; The Office file to be parsed includes at least one of the following items: Word file, Excel file, PowerPoint file, For the first version of the Office file to be parsed, the preset path includes at least one of the following items: Store the nested files of Word files in the word / media and word / embeddings folders of the file directory; Store the nested files of Excel files in the xl / media and xl / embeddings folders of the file directory; Store the nested files of the PowerPoint file in the ppt / media and ppt / embeddings folders of the file directory; For the second version of the Office file to be parsed, the preset path includes at least one of the following items: Mount the nested files of the Word file under the ObjectPool of the file directory; Mount the nested files of the Excel file under MBD in the file directory; Stores nested files of PowerPoint files in the PowerPoint Document data stream of the file directory.

6. A nested file parsing device, characterized in that: include: A determination module, used to determine a target Office file; A detection module is used to determine the target file type and file version of the Office file to be parsed at the current layer; A generation module, configured to parse the file directory according to the file directory parsing logic corresponding to the target file type and obtain the file directory corresponding to the file version of the Office file to be parsed; an output module, configured to output the file attribute information and file content of the Office file to be parsed according to the file directory, and convert the file content and / or file attributes of the Office file to be parsed into a parsed file corresponding to the target Office file, wherein the file content includes at least one or more of text, pictures, audio and video, compressed packages, and nested files; for text in the file content, convert the text into a text file in txt format; for pictures, audio and video, or compressed packages in the file content, output the corresponding pictures, audio and video, or compressed packages according to the original format of the file content; for nested files in the file content, output the Office file in the corresponding document format according to the file extension of the nested files; for icons of nested files in the file content, convert the icons of the nested files into image files in emf format; A judgment module, configured to determine whether there is a nested file in the Office file to be parsed according to the file directory; The nesting module is used to obtain the nested file if there is a nested file in the Office file to be parsed, and use the nested file as the Office file to be parsed, so that the detection module can continue to determine the target file type of the Office file to be parsed, specifically including (F1) if it is determined that there are multiple nested files in the Office file to be parsed, traverse the multiple nested files, and determine whether i is equal to m, where m is the number of nested files in the Office file to be parsed at the current layer, and the initial value of i is zero; (F2) if i is not equal to m, make i=i+1, and use the i-th nested file as the Office file to be parsed at the current layer, and return to execute step (B); (F3) if i is equal to m, complete the parsing of the Office file to be parsed.

7. An electronic device, characterized in that: include: A processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus, and the processor executes the machine-readable instructions to perform the steps of the file parsing method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which, when executed by a processor, executes the steps of the file parsing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Nested document extraction method and device, electronic equipment and storage medium

    CN111488556A

  • File analysis method and device, computer equipment and storage medium

    CN113051231A