Word file online structured display and editing method

By converting Word files into HTML rich text and performing structured parsing, the problem of chapter-level control that cannot be achieved in existing technologies is solved, enabling efficient collaborative editing and refined management of Word files, thus improving editing efficiency and user experience.

CN121835601APending Publication Date: 2026-04-10BEIJING SHENZHOU AEROSPACE SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-27
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies cannot achieve chapter-level permission control, version control, lifecycle status control, and collaborative editing of Word documents, resulting in low editing efficiency and failing to meet the needs of multi-person collaborative editing.

Method used

The Word file is converted into HTML rich text format, structured parsing is performed, the relationship between titles and chapters is identified, and the data is stored in a relational database. This enables chapter-level access control, lifecycle status management, and version control, and allows for real-time collaborative editing through WebSocket technology.

Benefits of technology

It enables fine-grained management and efficient editing of Word documents, supports collaborative editing by multiple users, improves editing efficiency and user experience, and provides chapter-level permission control and version tracking capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121835601A_ABST
    Figure CN121835601A_ABST
Patent Text Reader

Abstract

The invention discloses a Word file online structured display and editing method, and belongs to the technical field of information management. The method comprises the following steps: uploading a Word file to a file server; converting the Word file into an HTML (Hypertext Markup Language) rich text format, and processing picture resources in the Word file; performing structured analysis on the rich text, identifying titles and chapter contents, and establishing a hierarchical relationship and a sequential relationship between chapters; storing the analyzed structured data into a relational database; based on the structured data, tree structure display and rich text editing are carried out at a Web front end, and chapter-level authority control, life cycle state management, version control and multi-person collaborative editing are realized; and finally, merging all the modified chapter contents, and carrying out reverse writing to generate a final Word file. According to the invention, refined and collaborative management and efficient editing of the Word document are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information management technology, specifically to a method for online structured display and editing of Word documents. Background Technology

[0002] Online management and editing of Word documents is a common function in product data management systems and other information management systems. In practical applications, it is necessary to implement functions such as centralized server-side management of Word files, access control, collaborative writing, and version control.

[0003] Currently, online preview and editing management methods for Word documents mainly fall into two categories: One type involves a client that downloads the Word file from the server and uses its capabilities to view and edit it. After the designer finishes editing the Word file, the new content is uploaded to the server. The main process is as follows: Upload the initial Word file to the server and add additional descriptive information; assign corresponding viewing and editing permissions to the Word file; download the Word file; view or edit it using a local Word file editing tool; upload the new content to the server and update the original file content.

[0004] Another method involves converting Word files into a format recognizable by modern web browsers, allowing users to view and edit them on a webpage. The main process is as follows: The initial Word file is uploaded to the server, and additional descriptive information is added; corresponding viewing and editing permissions are assigned to the Word file; the user sends a viewing request to the server through their browser; the server converts the Word file into a browser-readable format and returns the file to the browser; the browser parses and renders the file; the user modifies the file in the browser; the user uploads the file back to the server; the server converts the file to Word format; and the Word file is stored on a file service.

[0005] However, both of the above-mentioned existing technologies have drawbacks: The first method relies on client-side capabilities for browsing and editing Word documents, requiring users to install the client and making it impossible for multiple people to edit the same Word document simultaneously. The second method depends on third-party professional web browsing tools, which are often expensive and have a complex and lengthy process, requiring users to wait a long time.

[0006] In addition, both methods mentioned above share a common drawback: 1. Browsing and editing are limited to the entire Word document and cannot provide precise chapter-level permission control. Therefore, it cannot support scenarios where user browsing and editing permissions need to be differentiated by chapter.

[0007] 2. It cannot provide precise version control down to the chapter level; it can only control the version of the entire Word document. Chapters that have not undergone content changes are also subject to version changes along with the overall Word document. This lack of specificity means that users cannot accurately identify content changes in specific chapters or trace historical version changes for those chapters.

[0008] 3. It cannot provide precise lifecycle status control down to the chapter level. When the content of a chapter in a Word document is finalized but other chapters are not, it cannot prevent users from editing the finalized chapters, which can easily lead to the pollution of the Word document content.

[0009] 4. The above two methods cannot provide chapter-level content approval process control. When the document design period is tight, the above two methods require waiting for all chapters of the Word document to be edited before the approval process can be initiated. Moreover, when different approvers are responsible for different content, it is not convenient and accurate to find the content to be approved. This solution can initiate the approval process before the entire Word document is completed when a certain chapter meets the approval conditions, which can save document design time.

[0010] Therefore, in summary, modern online documents are relatively complex in content, involve many writers, and involve complex operations such as document approval, collaboration, version control, and status control. Traditional online collaborative editing tools for Word documents cannot achieve chapter-level control, finer-grained permission control, version management, and lifecycle status control, resulting in a lack of focus in editing Word documents and low overall editing efficiency. Summary of the Invention

[0011] To address this issue, the present invention provides an online structured display and editing method for Word documents, thereby solving the problem that traditional Word document editing cannot control chapter levels in the prior art.

[0012] To achieve the above objectives, the present invention provides the following technical solution: A method for online structured display and editing of Word documents includes the following steps: S1: Upload the Word file to the file server and store it; S2: Convert the Word file to HTML rich text format and process the image resources within it; S3: Performs structured parsing of HTML rich text, identifies document titles and corresponding chapter content, and establishes hierarchical and sequential relationships between chapters; S4: Treat the parsed titles, chapter contents, and relational data as independent structured data; and store the structured data in a relational database; S5: Based on structured data, it displays tree-structured data and allows rich text editing on the web front end, and implements access control, lifecycle status management and version control for specified chapters; S6: Merge all the edited chapter contents according to the relationship described above, and reverse the process to generate the final Word file.

[0013] Furthermore: Structured parsing of HTML rich text, specifically including: By identifying HTML tags <h1>to <hn>To locate the document title; Associate all content following the heading and preceding the next heading at the same or higher level with the content of that heading as the chapter content under that heading. By comparing the hierarchy of adjacent headings, the parent-child relationship and sibling order between chapters can be determined.

[0014] Furthermore, access control includes setting separate read and edit permissions for different users for each chapter record in the relational database.

[0015] Furthermore, the access control supports an inheritance mechanism, with child chapters inheriting the access settings of their parent chapters by default.

[0016] Furthermore, the lifecycle status management includes: setting a status identifier for each chapter; when a chapter is in the "finalized" state, the system automatically prohibits editing of the chapter's content.

[0017] Furthermore, the version control includes: when the content of a chapter is modified, the system creates a new version record for that chapter and saves the historical version content, thereby enabling version tracing for a single chapter.

[0018] Furthermore, when performing rich text editing on the web front end, WebSocket technology can be used to synchronize the user's editing operations with other collaborating users who are editing the same chapter in real time.

[0019] Going a step further: it is implemented based on a microservice architecture, in which file storage, format conversion, structured parsing, and data persistence all run as independent microservices.

[0020] Furthermore: by calculating the hierarchical difference between adjacent headings Based on hierarchical differences The difference determines the parent-child relationship or sequential relationship between headings: The formula for calculating the hierarchical difference is: ; in, This represents the level value of the i-th heading; This indicates the level value of the previous heading. and All were parsed sequentially from the HTML rich text file; Indicates the difference in levels; The value directly determines the type of relationship between headings, specifically: like =1, the i-th heading is a subheading of the (i-1)-th heading; like If the value is 0, then the i-th heading and the (i-1)-th heading are at the same level. like If <0, then the i-th title needs to backtrack to find its ancestor title.

[0021] Furthermore: when The specific method for backtracking to find the ancestor title is as follows: 1) Maintain a stack S to store the title index of the current path; 2) For title i: Loop through the top of the stack until the top of the stack reaches the title level l. top <l i At this point, the top title of the stack becomes the parent title, so set parent(i) = top(S); and push the current title i onto the stack; maintain the path information; Where parent(i) represents the index of the parent title of the i-th title; top(S) represents the top element of stack S; S is a stack storing title indices, initially empty; top The level value of the top title in the stack; l i This is the value for the current title level.

[0022] This invention has the following advantages: It achieves refined, collaborative management and efficient editing of Word documents; specifically, by breaking down Word files into hierarchical chapters according to the heading hierarchy and storing each chapter independently, chapters can be edited and displayed independently; different chapters have their own version evolution process; different people have different permissions for different chapters within the same Word document; by storing chapter content in a database and utilizing the indexing capabilities of relational databases, rapid retrieval of chapter-level content is achieved, thereby enabling rapid previewing and editing of Word content; for finalized chapter content, the controlled status of the chapters can be set to protect the finalized content and prevent accidental modification; for chapter content requiring multiple approvals, some chapters can be submitted for review independently; thus, this invention has higher efficiency, a better user experience, greater functional scalability, and chapter-level management capabilities.

[0023] Other features and advantages of the present invention will be set forth in the following description. Attached Figure Description

[0024] To more intuitively illustrate the prior art and this application, exemplary drawings are provided below. It should be understood that the specific shapes and structures shown in the drawings should not generally be regarded as limiting conditions for implementing this application; for example, based on the technical concept disclosed in this application and the exemplary drawings, those skilled in the art are able to easily make conventional adjustments or further optimizations to the addition / reduction / classification, specific shapes, positional relationships, connection methods, size ratios, etc. of certain units (components).

[0025] Figure 1 A flowchart illustrating an online structured display and editing method for Word documents, as provided in this application embodiment. Detailed Implementation

[0026] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these embodiments are merely for further explanation of the present invention and should not be construed as limiting the scope of protection of the present invention. Those skilled in the art can make some non-essential improvements and adjustments to the present invention based on the above-described content.

[0027] Please see Figure 1 A method for online structured display and editing of Word documents, comprising the following steps: S1: Word file saving server In the process of managing Word files, they must first be stored on the server. The specific steps are as follows: (1) Users select a locally edited or incomplete draft; (2) Users upload documents to the corresponding location on the server according to the category of their personal documents or the relevant business domain.

[0028] S2: Word file format conversion Download the Word file from the file server to the file format conversion server; then convert the downloaded Word file into HTML rich text.

[0029] Specifically: After the Word file is uploaded, the backend automatically generates a Word file conversion task. This task converts the standard Word file into an HTML-based rich text format. The conversion program processes the HTML rich text and the images in the Word file separately. The image files are uploaded to the file server, and the file server returns the corresponding file links. The corresponding local image addresses in the HTML rich text are then replaced with the addresses from the file server.

[0030] This document format conversion is a prerequisite for the document content to be displayed on a webpage. Furthermore, HTML-based rich text has higher parsing efficiency and is easier to convert into a language for structured parsing. Its original data is based on text, which is convenient for reading and processing related parsing issues. Moreover, it occupies less storage space, which is beneficial for storage in relational databases, thereby further facilitating the use of the powerful data processing capabilities of relational databases.

[0031] The system automatically triggers a conversion task to convert Word files stored on the file server into HTML rich text format. During this process, images within the document are specially processed: they are uploaded to the file server and their network access links are obtained to replace the original local temporary paths in the HTML, ensuring that the images display correctly on the web.

[0032] S3: Structured Analysis The HTML rich text generated in step S2 above is subjected to structured parsing. By identifying the content of each heading in the Word document, the parent-child hierarchical relationship between them, and the order of the content of each heading, structured chapter data is constructed.

[0033] Specifically, it includes: (1) Title recognition Identify the heading tags H1-Hn in the HTML rich text file and their corresponding headings in the Word document. Read the content of the HTML rich text file in sequence and record the reading heading content.

[0034] (2) Associated title and chapter data The title is followed by the chapter content. If the content on the next line after the title is not the title, then the value of the subsequent content can be used as the content of this title, and their relationship is recorded in the relational database.

[0035] (3) Chapter content processing Images in the chapter content require special handling because the parsed images are stored on the server's local disk. In a distributed microservice business scenario, the client connects to random servers, so the image files need to be stored in the same file storage location (file server). Then, the file links returned by the file server are used to replace the content of the original HTML rich text img tags, and the processed chapter content is saved.

[0036] (4) Handling the relationship between chapters Since the relationships between chapters in a Word file are expressed through headings, it is necessary to extract the relationships between the headings in the HTML rich text file. During the reading of the HTML rich text file, the reading headings are stored using a queue data structure. Different heading levels are distinguished by reading the heading tags (H1-Hn). The level values ​​of adjacent headings are compared to determine whether to save the parent-child relationship or the sequential relationship between headings.

[0037] Specifically: it involves calculating the hierarchical difference between adjacent headings. ), and based on this difference, determine the parent-child relationship or sequential relationship between headings: The formula for calculating the hierarchical difference is: ; in, The level value (Level) of the i-th heading is a positive integer; ∈{1,2,3,…,n} (where n is the highest heading level, such as H1=1, H2=2, ..., Hn=n); This represents the level value of the previous heading (i-1), which is also a positive number, and its value is related to... They are identical and are all parsed sequentially from HTML rich text. Indicates the difference in levels; The value directly determines the type of relationship between headings, specifically: like =1, the i-th title is a subtitle of the (i-1)-th title (parent-child relationship); like If the value is 0, then the i-th heading and the (i-1)-th heading are sibling headings (they are related by precedence, i.e., they are related by brotherhood). like If <0, then the i-th title needs to backtrack to find its ancestor title (i.e., it needs to dynamically find its parent title using a stack). The specific method for backtracking to find ancestral titles is as follows: 1) Maintain a stack S (the top element of the stack must be less than the current title level) to store the title index of the current path; 2) For title i: Loop through the top of the stack until the top of the stack reaches the title level l. top <l i At this point, the top title of the stack is the parent title (that is, the parent of the current title i points to the top title of the stack), so set parent(i) = top(S); and push the current title i onto the stack; maintain the path information.

[0038] Where parent(i) represents the index of the parent title of the i-th title; top(S) represents the top element of stack S; S is a stack storing title indices, initially empty; top The level value of the top title in the stack; l i This is the value for the current title level.

[0039] S4: Data Preservation and Structured Content Display The previously parsed title content, chapter content, and relationships between chapters are saved to a relational database; and relevant permissions and lifecycle states are initialized.

[0040] When a user needs to view the content of a corresponding Word file on a webpage, the execution of the aforementioned step S3 generates structured data for the relevant Word file; the Word file ID is used to query the relational database to retrieve all relevant chapters, titles, and the relationships between chapters (utilizing the indexing capabilities of the relational database).

[0041] Once all the data has been queried into the server's memory, it will be organized into a data structure that is easy for the front end to use based on the relationships between chapters. Then, the data will be returned to the browser, and relevant front-end tree structure controls will be used to display the title tree structure, and relevant rich text controls will be used to display the rich text content of the relevant chapters.

[0042] S5: Structured Management of Chapter Content Based on independently stored chapter data, the following fine-grained controls are achieved: a. Permission settings Based on the chapter content, different users can be assigned to different chapters, and users can be granted viewing or editing permissions; and chapter permissions can be quickly inherited and passed on based on the chapter hierarchy.

[0043] b. Chapter content editing Users select the corresponding chapters of a Word file to edit based on their permissions and specific needs; then submit the edited content to the server, which processes and saves the chapter content.

[0044] c. Access Management When different chapters of the same Word file have different content, security levels, or professional backgrounds, different users will also focus on different chapters. In this case, it is necessary to control the access permissions for the chapters.

[0045] d. Collaborative editing Different users can edit different chapters simultaneously because each chapter is stored in a separate record in the database and is independent of the others. Combined with WebSocket long connections, users can broadcast their real-time edits to the server, synchronizing the broadcast content to the browsers of other collaborating users. This enables real-time sharing of edited content, facilitates real-time communication among colleagues, and improves the overall efficiency of document editing.

[0046] e. Lifecycle Status Management The completeness of the content varies for different chapters. When a user believes that the content of a certain chapter is complete, the user can choose to initiate a process and select the relevant executor. After the process is completed, the corresponding chapter will be finalized and its status will be set to unmodifiable.

[0047] S6: Reverse Word document Once all editing and approval processes are complete, perform a reverse write operation; extract the latest content of all chapters from the database in sequence; based on the hierarchical relationship of the chapters, concatenate the titles and content into a complete HTML rich text; call the document conversion service to convert this HTML rich text into a standard Word file; The generated final Word file is saved to a file server and associated with and bound to relevant business objects.

[0048] Example Let's take a product data management system as an example to implement the method of this invention.

[0049] Environment Preparation: Deploy a highly available file server cluster (such as FastDFS or cloud storage) to store original Word files and image resources; build a Word to HTML microservice cluster, using Aspose.Words or LibreOffice headless mode for format conversion; build a structured parsing microservice, using languages ​​such as Java / Python to develop the parsing logic; use a MySQL relational database to store the structured chapter data, permissions, status, and version information; the front end uses the Vue / React framework, integrating a tree control and a rich text editor, and maintains a long connection with the server via WebSocket.

[0050] The process execution status is as follows: (1) User "Zhang San" uploaded a copy of "Product Requirements Specification.docx" to the system; (2) The system automatically converts it into HTML and stores the parsed sections (such as "1. Introduction", "1.1 Background", "2. Functional Requirements", etc.) into the database; (3) Zhang San, as the administrator, sets permissions for the chapters: the chapter "2.1 User Management" is assigned to "Li Si" (read and write permissions), the chapter "2.2 Permission Management" is assigned to "Wang Wu" (read and write permissions), and other chapters are only readable and writable by himself; (4) Li Si and Wang Wu can be online at the same time and edit the chapters they are responsible for in their respective browsers. When Li Si is editing "2.1 User Management", the content he enters is displayed on Wang Wu's screen in real time via WebSocket (if Wang Wu is also viewing the chapter).

[0051] (5) After Li Si finishes editing, he sets the chapter status to "pending approval" and submits it; Project Manager "Zhao Liu" receives the notification and approves it, and the chapter status automatically changes to "finalized" and is locked; At this time, the "2.2 Access Control" chapter, which Wang Wu was in charge of, was still being edited and did not affect the finalized "2.1 User Management" chapter.

[0052] (6) Once all chapters are finalized, the system triggers the reverse writing process to generate the final "Product Requirements Specification_v1.0.docx" and archives it to the file server.

[0053] During this process, the modification history of each chapter is recorded, and users can click on any chapter to view its version differences from V1.0 to V1.3; through the API interface, the generated Word document can be associated with tasks in project management.

[0054] The method of the present invention has the following advantages: 1. Improved preview and editing speed; after the Word file is parsed, it is stored in a relational database. The B+ tree indexing capability of the relational database can be used to quickly extract relevant chapter data from the database. In addition, because the chapter data is stored independently, multiple users can edit the same Word document simultaneously.

[0055] 2. Chapter-level access control; because chapters are stored independently, each chapter has its own unique ID and can be edited independently. Users can assign different users and different permission items to different chapters as needed. 3. Chapter-level lifecycle status control; because different chapters express different themes or are edited by different users, the maturity of the content in different chapters varies at the same time. For chapters with complete content, they can be submitted for review independently and their lifecycle status can be set.

[0056] 4. Chapter-level version control: When version control of a Word file is required, the traditional approach is to apply unified version control to the entire Word file. However, in actual business scenarios, it is often only some chapters of the Word file that change. Since the structured chapter content is stored in different storage spaces, independent version control can be applied to achieve targeted tracing of historical records.

[0057] 5. Convenient chapter hierarchy modification capability; When the hierarchy between chapters in a Word document needs to be adjusted extensively, the structured chapter data is presented in a tree structure in the browser, which can clearly show the hierarchical relationship of the chapters. Using the mature and convenient tree structure adjustment tool on the front end, the chapter hierarchy can be visually and conveniently changed by dragging and dropping.

[0058] 6. Collaborative editing capabilities: Because the Word file is converted to HTML rich text format and the content of different chapters is stored independently, the Word content can be forwarded and synchronized in real time during the editing process by utilizing WebSocket long connections and the server's user registration and forwarding capabilities.

[0059] Furthermore, this invention is based on a popular microservices framework design, and can be easily and quickly deployed and have its capabilities expanded through DevOps tools.

[0060] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.< / hn> < / h1>

Claims

1. A method for online structured display and editing of Word documents, characterized in that, Includes the following steps: S1: Upload the Word file to the file server and store it; S2: Convert the Word file to HTML rich text format and process the image resources within it; S3: Performs structured parsing of HTML rich text, identifies document titles and corresponding chapter content, and establishes hierarchical and sequential relationships between chapters; S4: Treat the parsed titles, chapter content, and relationship data as independent structured data; And store the structured data in a relational database; S5: Based on structured data, it displays tree-structured data and allows rich text editing on the web front end, and implements access control, lifecycle status management and version control for specified chapters; S6: Merge all the edited chapter contents according to the relationship described above, and reverse the process to generate the final Word file.

2. The method for online structured display and editing of Word documents according to claim 1, characterized in that, Structured parsing of HTML rich text includes: By identifying HTML tags <h1>to <hn> To locate the document title;< / hn> < / h1> Associate all content following the heading and preceding the next heading at the same or higher level with the content of that heading as the chapter content under that heading. By comparing the hierarchy of adjacent headings, the parent-child relationship and sibling order between chapters can be determined.

3. The method for online structured display and editing of Word documents according to claim 1, characterized in that, Access control includes setting separate read and edit permissions for different users for each chapter record in a relational database.

4. The method for online structured display and editing of Word documents according to claim 3, characterized in that, The access control supports an inheritance mechanism, whereby child chapters inherit the access settings of their parent chapters by default.

5. The method for online structured display and editing of Word documents according to claim 1, characterized in that, The lifecycle status management includes: setting a status identifier for each chapter; when a chapter is in the "finalized" state, the system automatically prohibits editing of the chapter's content.

6. The method for online structured display and editing of Word documents according to claim 1, characterized in that, The version control includes: when the content of a chapter is modified, the system creates a new version record for that chapter and saves the historical version content, thereby enabling version tracing for a single chapter.

7. The method for online structured display and editing of Word documents according to claim 1, characterized in that, When performing rich text editing on the web front end, WebSocket technology can be used to synchronize the user's editing operations with other collaborating users who are editing the same chapter in real time.

8. The method for online structured display and editing of Word documents according to claim 1, characterized in that, It is implemented based on a microservice architecture, in which file storage, format conversion, structured parsing, and data persistence all run as independent microservices.

9. The method for online structured display and editing of Word documents according to claim 1, characterized in that, By calculating the hierarchical difference between adjacent headings Based on hierarchical differences The difference determines the parent-child relationship or sequential relationship between headings: Hierarchical difference The calculation formula is: ; in, This represents the level value of the i-th heading; This indicates the level value of the previous heading. and All were parsed sequentially from the HTML rich text file; Indicates the difference in levels; The value directly determines the type of relationship between headings, specifically: like =1, the i-th heading is a subheading of the (i-1)-th heading; like If the value is 0, then the i-th heading and the (i-1)-th heading are at the same level. like If <0, then the i-th title needs to backtrack to find its ancestor title.

10. The method for online structured display and editing of Word documents according to claim 9, characterized in that, when The specific method for backtracking to find the ancestor title is as follows: 1) Maintain a stack S to store the title index of the current path; 2) For title i: Loop through the top of the stack until the top of the stack reaches the title level l. top <l i At this point, the top title of the stack becomes the parent title, so set parent(i) = top(S); and push the current title i onto the stack; maintain the path information; Where parent(i) represents the index of the parent title of the i-th title; top(S) represents the top element of stack S; S is a stack storing title indices, initially empty; top The level value of the top title in the stack; l i This is the value for the current title level.