Cross-format excel watermark injection and locking linkage protection method and system
By identifying the Excel format type and parsing it into a structured document object, generating watermark codes and establishing linkage relationships, the problem of inconsistent watermarking schemes for different Excel file formats is solved. This enables cross-format watermark injection and locking protection linkage, thereby improving the level of security protection.
Patent Information
- Application Number
- CN202611259655.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-24
Smart Images

Figure CN123158601A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information security technology, and in particular to a method and system for cross-format Excel watermark injection and locking linkage protection. Background Technology
[0002] In the insurance industry's information systems, business documents such as proposals and benefit illustration forms often need to be exported to Excel format for clients or agents to view. To prevent document tampering or unauthorized distribution, watermarks are usually added to Excel and cell lock protection is set.
[0003] For XSSF format Excel documents, existing solutions typically use the Apache POI XSSFSheet API to set a worksheet background image to achieve a watermark effect, while simultaneously calling the `protectSheet` method to add worksheet protection. For HSSF format documents, since their underlying structure does not support worksheet background images, existing solutions usually abandon the watermark function or convert the document to XSSF format before processing. Furthermore, some solutions use third-party libraries such as EasyExcel to export data, but these libraries themselves do not provide watermark functionality and require secondary processing via the POI API after export. In scenarios involving large-scale data export, SXSSF streaming is commonly used, but the worksheet object is an SXSSFSheet rather than an XSSFSheet, making it impossible to directly set a background image for it using existing solutions.
[0004] However, the aforementioned existing technologies have several shortcomings. Existing watermarking schemes typically only support XSSF format. HSSF format, due to differences in its underlying structure, cannot use the same watermarking scheme, resulting in inconsistent security protection levels for documents exported from different formats. SXSSF streaming write scenarios lack direct support, requiring additional special processing to access the underlying XSSFWorkbook object. Watermark injection and cell locking protection logic are usually implemented separately in different parts of the business code, increasing code complexity and easily leading to situations where only watermarking is added without setting protection, or vice versa. Existing solutions typically use the system default font to render watermarks, which can easily result in squares or garbled characters for Chinese watermarks, and cannot flexibly switch font styles according to business needs. HSSF format generally suffers from missing watermarks; existing solutions either do not add watermarks to XLS format or require format conversion, increasing unnecessary processing overhead.
[0005] Therefore, there is an urgent need to provide a technical solution to address the above problems. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides a method and system for cross-format Excel watermark injection and locking linkage protection.
[0007] Firstly, the present invention provides a method for cross-format Excel watermark injection and locking linkage protection, the technical solution of which is as follows: Obtain the Excel file to be processed and identify the format type of the Excel file; Select the corresponding parsing strategy based on the format type to parse the Excel file into a structured document object; Obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code; The watermark image is embedded in a cell of the structured document object, and the watermark code is injected into a specified tag in the attribute file of the structured document object; Based on the correspondence between the cell's position information and the specified label, establish a linkage between the watermark image and the watermark code; A locking operation is performed on the attribute file after the watermark encoding is injected. After the locking is completed, a corresponding encapsulation strategy is selected according to the format type to encapsulate the structured document object carrying the watermark image, the watermark encoding and the linkage association into an Excel file corresponding to the format type.
[0008] The beneficial effects of the cross-format Excel watermark injection and locking linkage protection method of the present invention are as follows: The method of this invention identifies the Excel format type and selects a parsing strategy to parse it into a structured document object. It encrypts the original watermark information to generate a watermark code and image, embeds the watermark image into the cell, and injects the watermark code into the attribute file tag. It establishes a linkage between the watermark image and the watermark code based on the correspondence between the cell position and the attribute tag. After locking the attribute file, it encapsulates it according to the format type. This method solves the problems of inconsistent watermarking schemes for different Excel formats, scattered and easily overlooked watermark injection and locking protection, missing HSSF format watermarks, and lack of direct support for SXSSF streaming writing. It realizes cross-format Excel watermark injection and locking protection linkage, and improves the security level of document anti-tampering and unauthorized dissemination.
[0009] Based on the above solution, the cross-format Excel watermark injection and locking linkage protection method of the present invention can be further improved as follows.
[0010] In one alternative approach, the step of selecting a corresponding parsing strategy based on the format type to parse the Excel file into a structured document object includes: When the format type is a first format based on Office Open XML or a second format written in streaming mode, the Excel file is split into multiple XML components using an Office Open XML parsing method, and the multiple XML components are mapped to multiple generic markup language texts of the structured document object; When the format type is a third format based on a compound document structure, the Excel file is split into multiple record streams using a compound document-based parsing method, and the multiple record streams are mapped to multiple general markup language texts of the structured document object.
[0011] The advantages of adopting the above optional methods are: further distinguishing between the first format based on Office Open XML, the second format based on streaming writing, and the third format based on a composite document structure, splitting the first two formats into multiple XML components, splitting the third format into multiple record streams, and uniformly mapping them to generic markup language text, so that different Excel formats have a consistent structured processing foundation.
[0012] In one optional approach, the steps of performing encryption operations on the original watermark information to generate a watermark code, and generating a watermark image based on the watermark code, include: Obtain the user account identifier and the current access time, and concatenate the user account identifier and the current access time into a string to be encrypted; The string to be encrypted is hashed using the MD5 encryption algorithm to generate a hexadecimal string as the watermark code. According to the pixel encoding rules of the predetermined image format, each hexadecimal character of the watermark encoding is mapped to the pixel color value and transparency value of the watermark image to generate the watermark image.
[0013] The advantages of using the above optional method are as follows: after concatenating the user account identifier with the current access time, MD5 hash operation is performed to generate a hexadecimal watermark code, and the hexadecimal characters of the watermark code are mapped to pixel color values and transparency values according to the pixel encoding rules, so that the watermark image carries encrypted traceability information and avoids the content being read directly.
[0014] In one alternative approach, the steps of embedding the watermark image into a cell of the structured document object and injecting the watermark encoding into a specified tag in the attribute file of the structured document object include: The binary data of the watermark image is inserted into the first generic markup language text of the structured document object, and a reference tag of the watermark image is inserted into the second generic markup language text; Insert the position coordinates and size data of the watermark image in the structured document object into the third general markup language text; The associated tags of the watermark code are inserted into the fourth and fifth general markup language texts of the attribute file, respectively, and the watermark code is written into the attribute value of the specified tag.
[0015] The advantages of using the above optional method are as follows: the binary data, reference tags, and position coordinates of the watermark image are further inserted into different general markup language texts of the structured document object, and the associated tags of the watermark encoding are inserted into the general markup language text of the attribute file and the encoding is written into the attribute value of the specified tag, thereby realizing the distributed storage of watermark images and encodings.
[0016] In one optional approach, the step of establishing a linkage between the watermark image and the watermark code based on the correspondence between the cell's position information and the specified label includes: Obtain the row index and column index of the cell in the structured document object, and combine the row index and column index to form the position information of the cell; Obtain the tag name of the specified tag in the attribute file, and establish a mapping relationship between the location information and the tag name; The linkage association is generated based on the mapping relationship, and the linkage association includes the identifier of the watermark image, the watermark code, and the position information of the cell.
[0017] The beneficial effects of adopting the above optional method are as follows: further combining the row index and column index of the cell into location information, establishing a mapping relationship between the location information and the specified label name in the attribute file, generating a linkage association containing the watermark image identifier, watermark code and cell position, so that the watermark image and the code form a mutually corroborating correspondence.
[0018] In one alternative approach, the step of performing a locking operation on the attribute file after the watermark encoding is injected, and then selecting a corresponding encapsulation strategy based on the format type after locking, to encapsulate the structured document object carrying the watermark image, the watermark encoding, and the associated structured document object into an Excel file corresponding to the format type, includes: Set the access permission of the specified tag in the attribute file to read-only to complete the locking operation; After the locking is completed, the corresponding encapsulation strategy is selected according to the format type; When the format type is the first format or the second format, the structured document object is packaged into an Excel file based on Office Open XML according to the encapsulation strategy; when the format type is the third format, the structured document object is packaged into an Excel file based on a composite document structure according to the encapsulation strategy.
[0019] The advantages of using the above optional method are: further setting the access permission of the specified tag storing the watermark code in the attribute file to read-only to prevent the code from being modified or deleted, and at the same time selecting the corresponding encapsulation strategy according to the format type, so that the document can be restored to its original format while retaining the watermark and the locked state.
[0020] In one alternative approach, after establishing the linkage between the watermark image and the watermark code, the method further includes: Obtain the current storage information of the cell, wherein the current storage information includes the identifier of the image currently stored in the cell; Based on the position information of the cell in the linkage association, find the specified tag that has the mapping relationship with the position information, and extract the watermark code stored in the specified tag; The identifier of the currently stored image is compared with the identifier of the watermarked image in the linked association, and the watermark code stored in the specified tag is compared with the watermark code in the linked association. When the identifier of the currently stored image is inconsistent with the identifier of the watermarked image in the linked association, or when the watermark code stored in the specified tag is inconsistent with the watermark code in the linked association, it is determined that the watermark information of the structured document object has been tampered with.
[0021] The advantages of using the above optional method are: further obtain the identifier of the currently stored image in the cell, compare it with the watermark image identifier recorded in the linkage association, and at the same time verify whether the watermark code stored in the attribute file is consistent with the watermark code in the linkage association. If there is a discrepancy, it is determined that the watermark information has been tampered with.
[0022] Secondly, this invention provides a cross-format Excel watermark injection and locking linkage protection system, the technical solution of which is as follows: The identification module is used to acquire the Excel file to be processed and identify the format type of the Excel file; The parsing module is used to select the corresponding parsing strategy according to the format type and parse the Excel file into a structured document object; The generation module is used to obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code. The processing module is used to embed the watermark image into a cell of the structured document object and inject the watermark code into a specified tag in the attribute file of the structured document object; A module is established to create a linkage relationship between the watermark image and the watermark code based on the correspondence between the position information of the cell and the specified label. The encapsulation module is used to perform a locking operation on the attribute file after the watermark encoding is injected, and after the locking is completed, select the corresponding encapsulation strategy according to the format type to encapsulate the structured document object carrying the watermark image, the watermark encoding and the linkage association into an Excel file corresponding to the format type.
[0023] The beneficial effects of the cross-format Excel watermark injection and locking linkage protection system of the present invention are as follows: The system of this invention identifies the Excel format type and selects a parsing strategy to parse it into a structured document object. It encrypts the original watermark information to generate a watermark code and image, embeds the watermark image into the cell, and injects the watermark code into the attribute file tag. It establishes a linkage between the watermark image and the watermark code based on the correspondence between the cell position and the attribute tag. After locking the attribute file, it encapsulates it according to the format type. This solves the problems of inconsistent watermarking schemes for different Excel formats, scattered and easily overlooked watermark injection and locking protection, missing HSSF format watermarks, and lack of direct support for SXSSF streaming writing. It realizes cross-format Excel watermark injection and locking protection linkage, and improves the security level of document anti-tampering and unauthorized dissemination.
[0024] Thirdly, the technical solution of an electronic device according to the present invention is as follows: It includes a memory, a processor, and a program stored in the memory and running on the processor, wherein the processor executes the program to implement the steps of the cross-format Excel watermark injection and locking linkage protection method of the present invention.
[0025] Fourthly, the technical solution of a computer-readable storage medium provided by the present invention is as follows: The computer-readable storage medium stores instructions that, when read by the computer-readable storage medium, cause the computer-readable storage medium to perform the steps of the cross-format Excel watermark injection and locking linkage protection method of the present invention.
[0026] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other objects, features and advantages of the present invention more obvious and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0027] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 This is a flowchart illustrating an embodiment of the cross-format Excel watermark injection and locking linkage protection method of the present invention; Figure 2 This is a schematic diagram of the overall architecture; Figure 3 A schematic diagram of the watermark injection process; Figure 4 A diagram illustrating the tiling of a floating grid image in HSSF format; Figure 5 This is a schematic diagram of an embodiment of the cross-format Excel watermark injection and locking linkage protection system of the present invention; Figure 6 This is a schematic diagram of an embodiment of an electronic device according to the present invention. Detailed Implementation
[0028] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0029] Figure 1 This diagram illustrates a flowchart of an embodiment of a cross-format Excel watermarking injection and locking linkage protection method provided by the present invention. This method can be executed by electronic devices such as terminal devices or servers. The terminal device can be any fixed or mobile terminal, such as user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, or wearable device. The server can be a single server or a server cluster consisting of multiple servers. Any electronic device can implement the cross-format Excel watermarking injection and locking linkage protection method by having its processor call computer-readable instructions stored in its memory. Figure 1 As shown, it includes the following steps: S1. Obtain the Excel file to be processed and identify the format type of the Excel file.
[0030] The Excel file to be processed refers to an electronic spreadsheet file generated by the business system in the business information system that needs to be watermarked to prevent tampering or unauthorized dissemination. This file is stored in Excel format and contains business data. For example, Company A's business system generates a file named "Product Proposal B.xlsx", which contains business data such as customer name, insurance product name, insured amount and premium. This file needs to be exported for the customer to view, and it is the Excel file to be processed.
[0031] The format type refers to the underlying file storage specification followed by the Excel file to be processed, which is used to distinguish Excel files of different structural types. For example, the format type of the above-mentioned "B Product Proposal.xlsx" file is the first format based on Office Open XML, that is, the standard xlsx format. If the file is an xls format based on a compound document structure, then its format type is the third format. If the file is generated by streaming writing in a scenario of exporting large amounts of data, then its format type is the second format.
[0032] S2. Select the corresponding parsing strategy according to the format type and parse the Excel file into a structured document object.
[0033] The parsing strategy refers to the processing method used to convert the content of Excel files of different formats into a unified internal representation structure. This processing method includes file splitting and content mapping rules. For example, for the "B Product Proposal.xlsx" file of the first format mentioned above, the selected parsing strategy is the Office Open XML-based parsing method, that is, the file is split into multiple XML components according to the Office Open XML specification.
[0034] The structured document object refers to a document data structure uniformly organized in memory after parsing the original Excel file. This structure consists of multiple generic markup language texts and is used to mask underlying format differences. For example, after processing the "B Product Proposal.xlsx" file according to the parsing strategy, a structured document object containing multiple generic markup language texts such as worksheet data, style information, image relationships, and attribute information is obtained. This object is independent of the original xlsx or xls format.
[0035] S3. Obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code.
[0036] The original watermark information refers to the initial data used to generate the watermark. This data includes the user account identifier and the current access time, which are used to uniquely identify the document exporter and the export time. For example, when employee C exports "B Product Proposal.xlsx", the user account identifier is "user001" and the current access time is "2026-07-01 09:30:00". These two pieces of data together constitute the original watermark information.
[0037] The watermark encoding refers to a fixed-length string generated by encrypting the original watermark information. This string carries the watermark content in an encoded form. For example, "user001" and "2026-07-01 09:30:00" are concatenated to form the string "user0012026-07-01 09:30:00". Then, this string is encrypted using MD5 to obtain a hexadecimal string like "a1b2c3d4e5f67890", which is the watermark encoding. The watermark image refers to image data generated by converting the watermark encoding according to a predetermined image format pixel encoding rule. This image is used to embed in cells of an Excel document as a visual watermark. For example, each hexadecimal character of the watermark encoding "a1b2c3d4e5f67890" is mapped to a corresponding pixel color value and transparency value to generate a PNG format watermark image.
[0038] S4. Embed the watermark image into a cell of the structured document object, and inject the watermark code into a specified tag in the attribute file of the structured document object.
[0039] Here, a cell refers to the smallest data storage unit in an Excel file, uniquely determined by row and column indices, used to carry business data or embed watermark images. For example, in the structured document object "B Product Proposal.xlsx", the watermark image is embedded in the cell located in the 3rd row and 2nd column, which is the embedding position of the watermark image.
[0040] In this context, the attribute file refers to a file unit within the underlying storage structure of an Excel file specifically used to record document attribute information. This unit contains metadata such as the document creator, modification time, and custom tags. For example, for an Excel file based on Office Open XML, the attribute files are core.xml and custom.xml files under the docProps directory, which are used to store custom document attributes. The specified tag refers to a pre-defined internal location within the attribute file for storing a specific data tag with a watermark code. This tag has a unique tag name and is used to establish a mapping relationship with cell location information. For example, in the attribute file custom.xml, a specified tag named "WatermarkCode" is pre-defined, and the watermark code "a1b2c3d4e5f67890" is written into this specified tag.
[0041] S5. Based on the correspondence between the cell's position information and the specified label, establish a linkage relationship between the watermark image and the watermark code.
[0042] The location information refers to the coordinates of the cell within the structured document object. These coordinates are composed of row and column indices and uniquely identify the cell's location. For example, if the cell with the embedded watermark image is located in row 3 and column 2, then the cell's location information is a coordinate pair consisting of row index 3 and column index 2. The correspondence refers to the mapping relationship established between the cell's location information and a specified tag in the attribute file. This relationship is used for subsequent location and verification of the watermark data. For example, a one-to-one mapping relationship is established between the location information (row index 3, column index 2) and the tag name "WatermarkCode," meaning that the specified tag with the tag name "WatermarkCode" can be found using row index 3 and column index 2.
[0043] The linkage relationship refers to the binding relationship between the watermark image, the watermark code, and the cell position information. This relationship is used to check whether the three elements are consistent during subsequent verification. For example, the watermark image identifier "img001", the watermark code "a1b2c3d4e5f67890", and the cell position information (row index 3, column index 2) are bound into a linkage record. This record is used to verify the integrity of the watermark when the document is opened.
[0044] S6. Perform a locking operation on the attribute file after injecting the watermark code, and after locking, select the corresponding encapsulation strategy according to the format type, and encapsulate the structured document object carrying the watermark image, the watermark code and the linkage association into an Excel file corresponding to the format type.
[0045] The encapsulation strategy refers to the method of repackaging structured document objects carrying watermark images, watermark codes, and related information into Excel files of the corresponding format for different format types. For example, for the first format "B Product Proposal.xlsx", the encapsulation strategy is to package the structured document object into an xlsx file according to the Office Open XML encapsulation specification; for the third format xls file, the encapsulation strategy is to package it into an xls file according to the composite document encapsulation specification.
[0046] The technical solution of this embodiment identifies the Excel format type and selects a parsing strategy to parse it into a structured document object. It encrypts the original watermark information to generate a watermark code and image, embeds the watermark image into the cell, and injects the watermark code into the attribute file tag. It establishes a linkage between the watermark image and the watermark code based on the correspondence between the cell position and the attribute tag. After locking the attribute file, it encapsulates it according to the format type. This solves the problems of inconsistent watermarking schemes for different Excel formats, scattered and easily overlooked watermark injection and locking protection, missing HSSF format watermarks, and lack of direct support for SXSSF streaming writing. It realizes cross-format Excel watermark injection and locking protection linkage, and improves the security protection level of document anti-tampering and unauthorized dissemination.
[0047] Furthermore, the technical solution of this embodiment unifies the parsing of Excel files of different formats into a structured document object, enabling watermark injection, linkage, and locking operations to be performed on this unified object. This shields the underlying format differences and ensures consistent protection capabilities for all formats. Simultaneously, the linkage between the watermark image and the watermark code binds the visual layer and the data layer together. Tampering in either direction can be detected through the linkage verification. Combined with the locking operation on the attribute file, a collaborative protection mechanism is constructed from both data integrity and access control perspectives. This makes it difficult for attackers to modify the visual watermark or hidden code independently without disrupting the linkage relationship, thereby effectively improving the robustness of the protection.
[0048] In one alternative approach, the step of selecting a corresponding parsing strategy based on the format type to parse the Excel file into a structured document object includes: When the format type is a first format based on Office Open XML or a second format for streaming, the Excel file is split into multiple XML components using an Office Open XML parsing method, and the multiple XML components are mapped to multiple generic markup language texts of the structured document object.
[0049] The first format refers to the Excel file format based on Office Open XML, which corresponds to the standard .xlsx file and is composed of multiple XML components. For example, the aforementioned "Product Proposal B.xlsx" is an Excel file in the first format. The second format refers to the Excel file format generated by streaming. This format is also based on the Office Open XML structure, but it uses streaming processing during the writing process to support the export of large amounts of data. For example, when the exported "Product Proposal B" contains more than 100,000 rows of data, the system uses the SXSSF streaming writing method to generate the file, and the file format type is the second format.
[0050] In this context, XML components refer to the individual XML file units that are broken down according to the specifications in an Excel file based on Office Open XML. These units store worksheet data, styles, relationships, and attributes, respectively. For example, when parsing the first format "B Product Proposal.xlsx", it is split into multiple XML components such as sheet1.xml, styles.xml, sharedStrings.xml, and core.xml. Generic Markup Language (GML) text refers to the markup language text units in the structured document object used to carry different categories of data. These units correspond to the mapping content of the various components or record streams after the original Excel file has been split. For example, in the structured document object, the first GML text is used to store worksheet data, and the second GML text is used to store watermark image reference information.
[0051] When the format type is a third format based on a compound document structure, the Excel file is split into multiple record streams using a compound document-based parsing method, and the multiple record streams are mapped to multiple general markup language texts of the structured document object.
[0052] The third format refers to an Excel file format based on a composite document structure, which corresponds to a traditional xls file and is composed of multiple record streams at its underlying level. For example, if the Excel file to be processed is "B Product Proposal.xls", then the file format type is the third format.
[0053] Here, a composite document refers to a file storage structure that organizes the file content into multiple independent record streams, each storing different types of data. For example, the aforementioned third-format xls file is a composite document, containing multiple record streams such as workbook streams, worksheet streams, and string streams. The parsing method refers to the specific technical means used to convert the original Excel file into a structured document object. This means includes file structure recognition, component splitting, and content mapping. For example, for files in the first or second format, the parsing method is based on Office Open XML parsing, that is, reading each XML component in the file and mapping it to Generalized Markup Language (GMML) text; for files in the third format, the parsing method is based on composite document parsing, that is, reading each record stream in the file and mapping it to GMML text.
[0054] In this context, a record stream refers to binary data blocks stored in a certain order within a composite document structure, with each data block corresponding to a type of data content. For example, when parsing the above "B Product Proposal.xls", it is split into multiple record streams such as workbook record stream, worksheet record stream, and string record stream.
[0055] Among the above optional methods, we further distinguish between the first format based on Office Open XML, the second format based on streaming writing, and the third format based on a composite document structure. The first two formats are split into multiple XML components, and the third format is split into multiple record streams. They are uniformly mapped to generic markup language text, so that different Excel formats have a consistent structured processing foundation.
[0056] In one optional approach, the steps of performing encryption operations on the original watermark information to generate a watermark code, and generating a watermark image based on the watermark code, include: Obtain the user account identifier and the current access time, and concatenate the user account identifier and the current access time into a string to be encrypted.
[0057] The user account identifier is a unique string that identifies the user performing the operation. This string is used to record the identity information of the document exporter when generating the watermark. For example, employee C's user account identifier is "user001". The current access time is the system time when the user performs the document export operation. This time is used to record the document export time when generating the watermark. For example, employee C's current access time when exporting the document at 9:30 on July 1, 2026 is "2026-07-01 09:30:00".
[0058] The string to be encrypted refers to the original string obtained by concatenating the user account identifier and the current access time in a predetermined order, which is then input into the encryption algorithm. For example, the user account identifier "user001" and the current access time "2026-07-01 09:30:00" are concatenated to form "user0012026-07-01 09:30:00", which is the string to be encrypted.
[0059] The MD5 encryption algorithm is used to perform hash calculation on the string to be encrypted, and a hexadecimal string is generated as the watermark code.
[0060] According to the pixel encoding rules of the predetermined image format, each hexadecimal character of the watermark encoding is mapped to the pixel color value and transparency value of the watermark image to generate the watermark image.
[0061] The predetermined image format refers to the target image file format used when generating the watermark image, which includes standard image formats such as PNG and JPEG. For example, PNG format is used as the predetermined image format to generate the watermark image. The pixel encoding rule refers to the mapping specification that converts each character of the watermark encoding into the image pixel color value and transparency value. This specification determines the visual presentation of the watermark image. For example, following the pixel encoding rules of PNG images, each hexadecimal character of the watermark encoding "a1b2c3d4e5f67890" is mapped to the corresponding RGBA color value and transparency value, thereby generating the watermark image.
[0062] The pixel color value refers to the color channel value of a single pixel in the image, which includes the values of the red, green, and blue channels. For example, when generating a watermark image, the first character "a" of the watermark code is mapped to a pixel color value (red 255, green 128, blue 64). The transparency value refers to the transparency channel value of a single pixel in the image, which controls the light transmittance of that pixel. For example, when generating a watermark image, the second character "1" of the watermark code is mapped to a transparency value of 128, making the pixel appear semi-transparent.
[0063] In the above-mentioned optional methods, the user account identifier is further concatenated with the current access time and then subjected to MD5 hash operation to generate a hexadecimal watermark code. Based on the pixel encoding rules, the hexadecimal characters of the watermark code are mapped to pixel color values and transparency values, so that the watermark image carries encrypted traceability information and prevents the content from being read directly.
[0064] In one alternative approach, the steps of embedding the watermark image into a cell of the structured document object and injecting the watermark encoding into a specified tag in the attribute file of the structured document object include: The binary data of the watermark image is inserted into the first generic markup language text of the structured document object, and a reference tag of the watermark image is inserted into the second generic markup language text.
[0065] The reference tag refers to an identifier used in generic markup language text to mark the location of a watermark image. This tag is used to associate image data with its insertion position in the document structure. For example, the reference tag "pic:picRefimg001" is inserted into the second generic markup language text of the structured document object. This tag marks the reference of the watermark image.
[0066] Insert the watermark image into the third generic markup language text, specifying its position coordinates and size data within the structured document object.
[0067] The position coordinates refer to the positioning parameters of the watermark image within a cell of the structured document object, including horizontal and vertical offsets. For example, the position coordinates of the watermark image inserted into the third generic markup language text are a horizontal offset of 0.5cm and a vertical offset of 0.5cm. The size data refers to the width and height values of the watermark image when displayed within a cell of the structured document object. For example, the size data of the watermark image inserted into the third generic markup language text is a width of 3cm and a height of 1cm.
[0068] The associated tags of the watermark code are inserted into the fourth and fifth general markup language texts of the attribute file, respectively, and the watermark code is written into the attribute value of the specified tag.
[0069] The associated tag refers to a tag element used to insert watermark codes in the general markup language text of the attribute file. This tag has a unique tag name, is used to store the watermark codes, and establish an association with the cell position. For example, an associated tag is inserted in the fourth general markup language text of the attribute file.
[0070] In the above optional method, the binary data, reference tags, and position coordinates of the watermark image are further inserted into different general markup language texts of the structured document object. At the same time, the associated tags of the watermark encoding are inserted into the general markup language text of the attribute file, and the encoding is written into the attribute value of the specified tag, so as to realize the distributed storage of watermark images and encodings.
[0071] In one optional approach, the step of establishing a linkage between the watermark image and the watermark code based on the correspondence between the cell's position information and the specified label includes: Obtain the row index and column index of the cell in the structured document object, and combine the row index and column index to form the position information of the cell.
[0072] Obtain the tag name of the specified tag in the attribute file, and establish a mapping relationship between the location information and the tag name.
[0073] The label name refers to the unique identifier of the label specified in the attribute file. This name is used to map the label to the cell location information when establishing a linkage relationship. For example, the label name of the above-mentioned linkage label is "WatermarkCode", and this name is mapped to the location information (row index 3, column index 2).
[0074] The linkage association is generated based on the mapping relationship, and the linkage association includes the identifier of the watermark image, the watermark code, and the position information of the cell.
[0075] In the above optional methods, the row index and column index of the cell are further combined into location information, and a mapping relationship is established between the location information and the specified label name in the attribute file. This generates a linkage association containing the watermark image identifier, watermark code and cell position, so that the watermark image and the code form a mutually corroborating correspondence.
[0076] In one alternative approach, the step of performing a locking operation on the attribute file after the watermark encoding is injected, and then selecting a corresponding encapsulation strategy based on the format type after locking, to encapsulate the structured document object carrying the watermark image, the watermark encoding, and the associated structured document object into an Excel file corresponding to the format type, includes: Set the access permission of the specified tag in the attribute file to read-only to complete the locking operation.
[0077] After the locking is completed, the corresponding encapsulation strategy is selected according to the format type.
[0078] When the format type is the first format or the second format, the structured document object is packaged into an Excel file based on Office Open XML according to the encapsulation strategy; when the format type is the third format, the structured document object is packaged into an Excel file based on a composite document structure according to the encapsulation strategy.
[0079] In the above optional methods, the access permission of the specified tag storing the watermark code in the attribute file is further set to read-only to prevent the code from being modified or deleted. At the same time, the corresponding encapsulation strategy is selected according to the format type so that the document can be restored to its original format while retaining the watermark and the locked state.
[0080] In one alternative approach, after establishing the linkage between the watermark image and the watermark code, the method further includes: Obtain the current storage information of the cell, which includes the identifier of the image currently stored in the cell.
[0081] The currently stored information refers to the information related to the currently stored image obtained from the cell when verifying the watermark. This information includes the identifier of the currently stored image. For example, when opening "B Product Proposal.xlsx" for verification, the identifier of the currently stored image obtained from the cell in the 3rd row and 2nd column is "img001_modified".
[0082] The identifier refers to a string used to uniquely identify the watermark image. This string is assigned when the watermark image is generated and is bound to the cell position information and watermark code in the linkage association. For example, the identifier "img001" is assigned to the watermark image when it is generated. This identifier is recorded in the linkage association and is used to compare with the identifier in the currently stored information during subsequent verification.
[0083] Based on the location information of the cell in the linkage association, find the specified tag that has the mapping relationship with the location information, and extract the watermark code stored in the specified tag.
[0084] The identifier of the currently stored image is compared with the identifier of the watermarked image in the linked association, and the watermark code stored in the specified tag is compared with the watermark code in the linked association.
[0085] When the identifier of the currently stored image is inconsistent with the identifier of the watermarked image in the linked association, or when the watermark code stored in the specified tag is inconsistent with the watermark code in the linked association, it is determined that the watermark information of the structured document object has been tampered with.
[0086] In the above optional methods, the identifier of the currently stored image in the cell is further obtained and compared with the watermark image identifier recorded in the linkage association. At the same time, it is verified whether the watermark code stored in the attribute file is consistent with the watermark code in the linkage association. If there is a discrepancy, it is determined that the watermark information has been tampered with.
[0087] Figure 2 The overall architecture diagram of this embodiment is shown. Figure 2 As shown, the overall architecture includes an ExcelParam parameter module 101, a dynamic watermark image generator 102, a format adaptive distributor 103, an XSSF background image watermark module 104, an HSSF grid tiling watermark module 105, and a cell locking and worksheet protection module 106.
[0088] The ExcelParam parameter module 101 carries export parameters, including watermark text and export format configuration information. The dynamic watermark image generator 102 generates a transparent background PNG watermark image in memory. This generator supports anti-aliasing and font configuration loading, avoiding abnormal Chinese character display caused by the system default font by loading different font files. The format adaptive dispatcher 103 automatically detects the format type of the current workbook, including the first format based on Office Open XML, the second format based on streaming, and the third format based on a composite document structure. Based on the detection results, it distributes the watermark injection task to the corresponding processing module. When the format type is the first format, the XSSF background image watermark module 104 establishes a relationship between the image and the worksheet background through the PackagePartName in the Office Open XML relationship, thus injecting the background watermark. When the format type is the third format, the HSSF grid tiling watermark module 105 uses ClientAnchor floating anchors to achieve gridded image tiling, ensuring the watermark image evenly covers the entire worksheet area. The cell locking and worksheet protection module 106 is used to link cell locking style settings and worksheet password protection in the callback, ensuring that watermark injection and locking protection are completed sequentially in the same process. The format adaptive dispatcher 103 interacts with the XSSF background image watermarking module 104, the HSSF grid tiling watermarking module 105, and the cell locking and worksheet protection module 106 respectively. The watermark image generated by the dynamic watermark image generator 102 is passed to the XSSF background image watermarking module 104 and the HSSF grid tiling watermarking module 105 in the form of a PNG byte array. The ExcelParam parameter module 101 passes the watermark text and export format parameters to the format adaptive dispatcher 103, thus forming a complete processing chain from parameter configuration, watermark generation, format distribution to watermark injection and locking protection.
[0089] Figure 3 The detailed steps of the watermark injection process are shown. For example... Figure 3 As shown, the steps include: S201: The EasyExcel framework triggers the afterSheetCreate callback, which takes WriteWorkbookHolder and WriteSheetHolder objects as input.
[0090] S202: Call the createWatermarkImageBytes method to generate a PNG image byte array for the watermark. This image byte array is generated based on the watermark encoding generated after encryption of the original watermark information, and converted according to the pixel encoding rules of the predetermined image format. The image format is PNG.
[0091] S203: Detect the format type of the current Workbook instance. The format adaptive dispatcher determines whether the current instance belongs to the XSSFWorkbook type, SXSSFWorkbook type, or HSSFWorkbook type, and executes different watermark injection branches according to different format types.
[0092] S204: When a Workbook instance is detected to be of type XSSFWorkbook, the XSSF background image watermark module 104 calls the addXssfWatermark method to establish the association between the image and the worksheet background through the PackagePartName of Office Open XML, and sets the watermark image as the worksheet background.
[0093] S205: When a Workbook instance is detected to be of type SXSSFWorkbook, obtain the underlying XSSFWorkbook object of the SXSSFWorkbook and reuse the XSSF watermarking logic to perform watermark injection. This method avoids the restriction of directly manipulating SXSSFWorkbook.
[0094] S206: When a Workbook instance of type HSSFWorkbook is detected, the HSSF grid tiling watermark module 105 calls the addHssfWatermark method to achieve a watermark tiling effect by anchoring floating images in a grid according to a preset step size. The specific implementation method is as follows... Figure 3 Detailed description is provided.
[0095] S207: After completing the watermark injection branch described above, the cell locking and worksheet protection module 106 calls the `sheet.protectSheet` method to set worksheet password protection. This step is executed uniformly after watermark injection is completed, ensuring that watermark injection and locking protection are tightly connected in the process and avoiding any omission of any operation. Through the above process, the system can adaptively select the corresponding watermark injection strategy according to different format types and uniformly execute locking protection after watermark injection is completed, ensuring the sequential execution and linkage of watermark injection and locking operations.
[0096] Figure 4 This demonstrates the specific implementation method of HSSF format gridded floating image tiling watermark under the third format. For example... Figure 4 As shown, for Excel files in a third-formatted structure based on a compound document structure, the watermark tiling scheme is implemented according to the following steps: S301: Add the watermarked image generated by the dynamic watermark image generator 102 to the image list of the current Workbook. Obtain the pictureIdx index value corresponding to the image through the addPicture method. This index value is used for reference when inserting images later.
[0097] S302: Creates a Drawing Pattern object, which is the top-level container in the HSSF worksheet that manages floating graphics and is used to hold all floating image creation operations.
[0098] S303: Set tiling parameters, including row step length. Sum of steps ,in OK, Column, coverage set to Multiply This coverage ensures that the watermark image fills the entire visible area of the worksheet.
[0099] S304: Employs a double-loop structure, with the outer loop operating according to row step size. Incrementing, inner loop increments by column. Incrementally create ClientAnchor anchors one by one. Each anchor can precisely control the placement of the watermark image by setting the start row, start column, end row, end column, and horizontal and vertical offsets.
[0100] S305: For each created ClientAnchor anchor point, call the drawing.createPicture method, passing in the anchor point and the previously obtained pictureIdx index value, to insert a watermark image at that anchor point position. By iterating through all anchor points, a gridded tiling effect of the watermark image is achieved across the entire worksheet. The above tiling scheme is achieved by setting... lines and The step size of the column, in Multiply The watermark image is evenly distributed within the column's coverage area, ensuring that the third-format Excel file can achieve the same visual watermark coverage as the first and second formats, thereby guaranteeing a consistent level of security protection for cross-format documents.
[0101] In another embodiment of the cross-format Excel watermark injection and locking linkage protection method of the present invention, it includes: S10. Obtain the Excel file to be processed, identify the format type of the Excel file, and obtain the insurance business parameters, which include the product type code and the coverage level code.
[0102] S20. Select the corresponding parsing strategy according to the format type to parse the Excel file into a structured document object.
[0103] S30. Obtain the original watermark information, which includes the user account identifier, current access time, product type code, and coverage level code. Concatenate the original watermark information into a string to be encrypted, and perform encryption operations on the string to be encrypted to generate the watermark code.
[0104] S40. Generate a watermark image based on the watermark code, embed the watermark image into a cell of a structured document object, and inject the watermark code into a specified tag in the property file of the structured document object.
[0105] S50. Obtain the cell's location information, obtain the label name of the specified label in the attribute file, establish a mapping relationship between the location information and the label name, and generate a linkage association between the watermark image and the watermark code based on the mapping relationship. The linkage association includes the watermark image identifier, watermark code, cell location information, product type code, and coverage level code.
[0106] S60. Obtain the total number of cells in the structured document object, and calculate the lock strength coefficient based on the insurance level code and the total number of cells. The formula for calculating the lock strength coefficient is as follows: in, To lock the strength coefficient, For coverage level coding, The preset reference coverage level code, The total number of cells. The preset number of reference cells, and These are the preset weighting coefficients.
[0107] It should be noted that the above formula for calculating the locking strength coefficient is based on two dimensions: the coverage level code and the total number of cells. The coverage level code reflects the importance level of the insurance business document, and the total number of cells reflects the data scale and complexity of the document. By taking the ratio of the coverage level code to the preset reference coverage level code and the ratio of the total number of cells to the preset reference number of cells as inputs, and then weighting and summing them with preset weight coefficients, the nonlinear mapping of the S-shaped function is used to smoothly constrain the weighted result within the numerical range of zero to one. This makes the locking strength coefficient monotonically increase with the increase of the coverage level and the increase of the document size, thereby achieving adaptive adjustment of the locking strength of the attribute file, ensuring that high-value business documents receive stronger protection while low-value documents are not overprotected.
[0108] S70. Perform a locking operation on the attribute file according to the locking strength coefficient. The strength of the locking operation is positively correlated with the locking strength coefficient. After the locking is completed, select the corresponding encapsulation strategy according to the format type and encapsulate the structured document object carrying the watermark image, watermark code and linkage association into an Excel file corresponding to the format type.
[0109] The technical solution of this embodiment incorporates product type code and coverage level code into the original watermark information for encryption calculation to generate watermark code, and synchronously records insurance business parameters in the linkage association, so that the watermark carries a richer document traceability dimension. This solves the problem that the watermark code only contains user identification and time information and cannot reflect the document business attribute level. Furthermore, it adopts a locking strength coefficient calculation formula that includes coverage level code and total number of cells, and maps the document importance level and data scale together to the locking strength, so as to achieve adaptive adjustment of the locking strength of attribute files. This solves the problem that the existing solution uses a uniform locking strength for all documents, resulting in insufficient protection for high-value documents or excessive consumption of processing resources for low-value documents, and improves the matching degree between protection strategy and document importance level.
[0110] Figure 5 This diagram illustrates a structural schematic of an embodiment of a cross-format Excel watermark injection and locking linkage protection system 400 provided by the present invention. Figure 5 As shown, the cross-format Excel watermark injection and locking linkage protection system 400 includes: The identification module 401 is used to acquire the Excel file to be processed and identify the format type of the Excel file; Parsing module 402 is used to select the corresponding parsing strategy according to the format type and parse the Excel file into a structured document object; The generation module 403 is used to obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code. Processing module 404 is used to embed the watermark image into a cell of the structured document object and inject the watermark code into a specified tag in the attribute file of the structured document object; Module 405 is used to establish a linkage relationship between the watermark image and the watermark code based on the correspondence between the position information of the cell and the specified label. The encapsulation module 406 is used to perform a locking operation on the attribute file after the watermark encoding is injected, and after the locking is completed, select the corresponding encapsulation strategy according to the format type to encapsulate the structured document object carrying the watermark image, the watermark encoding and the linkage association into an Excel file corresponding to the format type.
[0111] In an alternative embodiment, the parsing module 402 is specifically used for: When the format type is a first format based on Office Open XML or a second format written in streaming mode, the Excel file is split into multiple XML components using an Office Open XML parsing method, and the multiple XML components are mapped to multiple generic markup language texts of the structured document object; When the format type is a third format based on a compound document structure, the Excel file is split into multiple record streams using a compound document-based parsing method, and the multiple record streams are mapped to multiple general markup language texts of the structured document object.
[0112] In an alternative embodiment, the generation module 403 is specifically used for: Obtain the user account identifier and the current access time, and concatenate the user account identifier and the current access time into a string to be encrypted; The string to be encrypted is hashed using the MD5 encryption algorithm to generate a hexadecimal string as the watermark code. According to the pixel encoding rules of the predetermined image format, each hexadecimal character of the watermark encoding is mapped to the pixel color value and transparency value of the watermark image to generate the watermark image.
[0113] In an alternative embodiment, the processing module 404 is specifically used for: The binary data of the watermark image is inserted into the first generic markup language text of the structured document object, and a reference tag of the watermark image is inserted into the second generic markup language text; Insert the position coordinates and size data of the watermark image in the structured document object into the third general markup language text; The associated tags of the watermark code are inserted into the fourth and fifth general markup language texts of the attribute file, respectively, and the watermark code is written into the attribute value of the specified tag.
[0114] In an alternative embodiment, the establishment module 405 is specifically used for: Obtain the row index and column index of the cell in the structured document object, and combine the row index and column index to form the position information of the cell; Obtain the tag name of the specified tag in the attribute file, and establish a mapping relationship between the location information and the tag name; The linkage association is generated based on the mapping relationship, and the linkage association includes the identifier of the watermark image, the watermark code, and the position information of the cell.
[0115] In an alternative embodiment, the encapsulation module 406 is specifically used for: Set the access permission of the specified tag in the attribute file to read-only to complete the locking operation; After the locking is completed, the corresponding encapsulation strategy is selected according to the format type; When the format type is the first format or the second format, the structured document object is packaged into an Excel file based on Office Open XML according to the encapsulation strategy; when the format type is the third format, the structured document object is packaged into an Excel file based on a composite document structure according to the encapsulation strategy.
[0116] In an alternative embodiment, the establishment module 405 is further configured to: Obtain the current storage information of the cell, wherein the current storage information includes the identifier of the image currently stored in the cell; Based on the position information of the cell in the linkage association, find the specified tag that has the mapping relationship with the position information, and extract the watermark code stored in the specified tag; The identifier of the currently stored image is compared with the identifier of the watermarked image in the linked association, and the watermark code stored in the specified tag is compared with the watermark code in the linked association. When the identifier of the currently stored image is inconsistent with the identifier of the watermarked image in the linked association, or when the watermark code stored in the specified tag is inconsistent with the watermark code in the linked association, it is determined that the watermark information of the structured document object has been tampered with.
[0117] It should be noted that the beneficial effects of the cross-format Excel watermarking injection and locking linkage protection system 200 provided in the above embodiments are the same as those of the cross-format Excel watermarking injection and locking linkage protection method described above, and will not be repeated here. Furthermore, the system provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the system can be divided into different functional modules according to the actual situation to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, and will not be repeated here.
[0118] The cross-format Excel watermark injection and locking linkage protection system 400 of the present invention can be a computer program (including program code) running on a computer device. For example, the cross-format Excel watermark injection and locking linkage protection system 400 of the present invention is an application software that can be used to execute the corresponding steps in the cross-format Excel watermark injection and locking linkage protection method of the present invention.
[0119] In some embodiments, the cross-format Excel watermark injection and locking linkage protection system 400 of the present invention can be implemented in a combination of hardware and software. As an example, the cross-format Excel watermark injection and locking linkage protection system 400 of the present invention can be a processor in the form of a hardware decoding processor, which is programmed to execute the cross-format Excel watermark injection and locking linkage protection method of the present invention. For example, the processor in the form of a hardware decoding processor can be one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0120] The modules described in the embodiments of this invention can be implemented in software or hardware. The names of the modules are not, in some cases, limiting the scope of the module itself.
[0121] An electronic device according to an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the above-mentioned cross-format Excel watermark injection and locking linkage protection methods. That is, an electronic device according to an embodiment of the present invention may include, but is not limited to: a processor and a memory; the memory is used to store the computer program; the processor is used to execute the cross-format Excel watermark injection and locking linkage protection method shown in any embodiment of the present invention by calling the computer program.
[0122] In one alternative embodiment, an electronic device is provided, such as Figure 6 As shown, Figure 6 The illustrated electronic device 5000 includes a processor 5001 and a memory 5003. The processor 5001 and the memory 5003 are connected, for example, via a bus 5002. Optionally, the electronic device 5000 may further include a transceiver 5004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 5004 is not limited to one type, and the structure of the electronic device 5000 does not constitute a limitation on the embodiments of the present invention.
[0123] Processor 5001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this invention. Processor 5001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0124] Bus 5002 may include a path for transmitting information between the aforementioned components. Bus 5002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 5002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The bus 5002 is represented by only one thick line, but this does not mean that there is only one bus or one type of bus.
[0125] The memory 5003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0126] The memory 5003 stores application code (computer program) for executing the present invention, and its execution is controlled by the processor 5001. The processor 5001 executes the application code stored in the memory 5003 to implement the content shown in the foregoing method embodiments.
[0127] Among them, electronic devices can also be terminal devices. A terminal device can be any terminal device that can install applications and access web pages through applications, including at least one of smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, smart TVs, and smart in-vehicle devices.
[0128] It should be noted that, Figure 3 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0129] An embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the above-mentioned cross-format Excel watermark injection and locking linkage protection methods.
[0130] Alternatively, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.
[0131] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the aforementioned cross-format Excel watermark injection and locking linkage protection method.
[0132] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0133] It should be understood that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0134] The computer-readable storage medium provided in this invention can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0135] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the method shown in the above embodiments.
[0136] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.
[0137] It should be noted that the terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of this application described herein can be implemented in an order other than that shown or described.
[0138] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this invention can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, this invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.
[0139] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A cross-format Excel watermark injection and locking linkage protection method, characterized in that, include: Obtain the Excel file to be processed and identify the format type of the Excel file; Select the corresponding parsing strategy based on the format type to parse the Excel file into a structured document object; Obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code; The watermark image is embedded in a cell of the structured document object, and the watermark code is injected into a specified tag in the attribute file of the structured document object; Based on the correspondence between the cell's position information and the specified label, establish a linkage between the watermark image and the watermark code; A locking operation is performed on the attribute file after the watermark encoding is injected. After the locking is completed, a corresponding encapsulation strategy is selected according to the format type to encapsulate the structured document object carrying the watermark image, the watermark encoding and the linkage association into an Excel file corresponding to the format type.
2. The cross-format Excel watermark injection and locking linkage protection method according to claim 1, characterized in that, The steps of selecting the corresponding parsing strategy based on the format type and parsing the Excel file into a structured document object include: When the format type is a first format based on Office Open XML or a second format written in streaming mode, the Excel file is split into multiple XML components using an Office Open XML parsing method, and the multiple XML components are mapped to multiple generic markup language texts of the structured document object; When the format type is a third format based on a compound document structure, the Excel file is split into multiple record streams using a compound document-based parsing method, and the multiple record streams are mapped to multiple general markup language texts of the structured document object.
3. The cross-format Excel watermark injection and locking linkage protection method of claim 1, wherein, The steps of performing encryption operations on the original watermark information to generate a watermark code, and generating a watermark image based on the watermark code, include: Obtain the user account identifier and the current access time, and concatenate the user account identifier and the current access time into a string to be encrypted; The string to be encrypted is hashed using the MD5 encryption algorithm to generate a hexadecimal string as the watermark code. According to the pixel encoding rules of the predetermined image format, each hexadecimal character of the watermark encoding is mapped to the pixel color value and transparency value of the watermark image to generate the watermark image.
4. The cross-format Excel watermark injection and locking linkage protection method of claim 1, wherein, The steps of embedding the watermark image into a cell of the structured document object and injecting the watermark code into a specified tag in the attribute file of the structured document object include: The binary data of the watermark image is inserted into the first generic markup language text of the structured document object, and a reference tag of the watermark image is inserted into the second generic markup language text; Insert the position coordinates and size data of the watermark image in the structured document object into the third general markup language text; The associated tags of the watermark code are inserted into the fourth and fifth general markup language texts of the attribute file, respectively, and the watermark code is written into the attribute value of the specified tag.
5. The cross-format Excel watermark injection and locking linkage protection method according to claim 1, characterized in that, The step of establishing a linkage between the watermark image and the watermark code based on the correspondence between the cell position information and the specified label includes: Obtain the row index and column index of the cell in the structured document object, and combine the row index and column index to form the position information of the cell; Obtain the tag name of the specified tag in the attribute file, and establish a mapping relationship between the location information and the tag name; The linkage association is generated based on the mapping relationship, and the linkage association includes the identifier of the watermark image, the watermark code, and the position information of the cell.
6. The cross-format Excel watermark injection and locking linkage protection method according to claim 2, characterized in that, The steps of performing a locking operation on the attribute file after injecting the watermark encoding, and selecting a corresponding encapsulation strategy according to the format type after locking, to encapsulate the structured document object carrying the watermark image, the watermark encoding, and the linked association into an Excel file corresponding to the format type, include: Set the access permission of the specified tag in the attribute file to read-only to complete the locking operation; After the locking is completed, the corresponding encapsulation strategy is selected according to the format type; When the format type is the first format or the second format, the structured document object is packaged into an Excel file based on Office Open XML according to the encapsulation strategy; when the format type is the third format, the structured document object is packaged into an Excel file based on a composite document structure according to the encapsulation strategy.
7. The cross-format Excel watermark injection and locking linkage protection method according to claim 5, characterized in that, After establishing the linkage between the watermark image and the watermark code, the method further includes: Obtain the current storage information of the cell, wherein the current storage information includes the identifier of the image currently stored in the cell; Based on the position information of the cell in the linkage association, find the specified tag that has the mapping relationship with the position information, and extract the watermark code stored in the specified tag; The identifier of the currently stored image is compared with the identifier of the watermarked image in the linked association, and the watermark code stored in the specified tag is compared with the watermark code in the linked association. When the identifier of the currently stored image is inconsistent with the identifier of the watermarked image in the linked association, or when the watermark code stored in the specified tag is inconsistent with the watermark code in the linked association, it is determined that the watermark information of the structured document object has been tampered with.
8. A cross-format Excel watermark injection and locking linkage protection system, characterized in that, include: The identification module is used to acquire the Excel file to be processed and identify the format type of the Excel file; The parsing module is used to select the corresponding parsing strategy according to the format type and parse the Excel file into a structured document object; The generation module is used to obtain the original watermark information, perform encryption operations on the original watermark information to generate a watermark code, and generate a watermark image based on the watermark code. The processing module is used to embed the watermark image into a cell of the structured document object and inject the watermark code into a specified tag in the attribute file of the structured document object; A module is established to create a linkage relationship between the watermark image and the watermark code based on the correspondence between the position information of the cell and the specified label. The encapsulation module is used to perform a locking operation on the attribute file after the watermark encoding is injected, and after the locking is completed, select the corresponding encapsulation strategy according to the format type to encapsulate the structured document object carrying the watermark image, the watermark encoding and the linkage association into an Excel file corresponding to the format type.
9. An electronic device, comprising: The electronic device includes a processor coupled to a memory, the memory storing at least one computer program, which is loaded and executed by the processor to enable the electronic device to implement the cross-format Excel watermark injection and locking linkage protection method as described in any one of claims 1 to 7.
10. A computer readable storage medium characterized by The computer-readable storage medium stores at least one computer program, which, when executed by a processor, implements the cross-format Excel watermark injection and locking linkage protection method as described in any one of claims 1 to 7.
