Method for realizing sorting and screening functions supported by PPT (Power Point Table) table

By using custom INI format script parsing and data processing instructions, the sorting and filtering functions of PPT tables are implemented, solving the problem of the lack of this function in PPT tables, providing a user-friendly data processing method, and ensuring data validity and consistency.

CN121580978APending Publication Date: 2026-02-27CHINA LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511551394.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

PPT tables lack sorting and filtering functions, failing to meet the diverse needs of users in data rendering scenarios.

Method used

By using a custom INI format script, the XML object of the PPT table is parsed to generate a data processing instruction object, which performs data filtering and sorting operations, replaces the filtered data in the PPT table, and deletes redundant table rows, thus realizing the sorting and filtering functions of the PPT table.

Benefits of technology

No coding is required; users can filter and sort data by filling in scripts in INI format. The operation is convenient, ensuring that the amount of data after processing is consistent with the original range, avoiding redundancy, and the table only retains valid data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121580978A_ABST
    Figure CN121580978A_ABST
Patent Text Reader

Abstract

The invention provides a method for realizing sorting and screening supporting functions of a PPT table, which comprises the following steps of: S1, receiving a PPT file input by a user, and creating a PPT object; s2, circularly traversing a Table table object in the PPT object, and putting the Table table object into a List set with the name of a table List; s3, reading a script in a self-defined format of the Table table object, and generating a data processing instruction object; s4, preparing data to be filtered in the Table table object; s5, filtering the data; s6, sorting the data; s7, replacing the data in the Table table object; s8, deleting redundant table lines in the Table table object; and S9, generating a PPT file by the PPT object, and returning a result. On the basis of the script in the self-defined format, by analyzing the script, executing corresponding data screening and data sorting operation, replacing the screened data into the PPT table and deleting redundant PPT table rows, sorting and screening of the data in the PPT table are completed, and the PPT table supports sorting and screening functions.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and particularly relates to a method for realizing sorting and filtering functions of a PPT table. BACKGROUND

[0002] At present, an Excel table supports sorting and filtering functions, and a user can filter and sort data in the table according to different requirements, which is very convenient. However, a PPT table does not have similar functions. In a data rendering scene using a PPT as a template, a user often needs the PPT table to support sorting and filtering functions, which can facilitate data processing and meet diversified requirements. Therefore, a method is needed to realize sorting and filtering functions of a PPT table. SUMMARY

[0003] The present application aims at solving the problems in the prior art and provides a method for realizing sorting and filtering functions of a PPT table. EMBODIMENT

[0004] To achieve the above object, the present application adopts the following technical scheme: a method for realizing sorting and filtering functions of a PPT table, comprising the following steps: S1: receiving a PPT file input by a user and creating a PPT object; S11: receiving a PPT file input by a user; S12: checking whether the PPT file is null. When the PPT file is null, the checking is failed, error information is returned, and the process is ended. When the PPT file is a file complete path, a file input stream object, a file object or a file byte array, the checking is passed, and the process proceeds to step S13; S13: creating the PPT file into a file stream object, creating the file stream object into a buffer stream object, and creating the buffer stream object into a PPT object; S2: looping through Table table objects in the PPT object and putting them into a List collection named tableList; S21: looping through Slide slide objects in the PPT object; S22: looping through Shape shape objects in the Slide slide object; S23: judging whether the Shape shape object is a Table table object by using an instanceof keyword. If yes, the Shape shape object is forcibly converted into a Table table object and stored in the List collection named tableList, and the element is a Table table object. If not, the process is skipped and S22 is continuously executed until the looping is completed; S3: read the script of the custom format of the Table table object, and generate a data processing instruction object; S31: obtain the number of elements by the size() method of the List collection, and determine whether the number of elements in the List collection tableList is 0, if yes, end the rendering, if not, continue to the next step; S32: loop through each element Table table object in the List collection tableList; S33: locate the optional text description attribute from the XML object of the Table table object through the path syntax of xml, read the value of the description, which is a custom script string; The custom script is in INI format, and the custom script is composed of sections, keys and values; The section must contain Data, and also contains Filter and / or Order; The content of the section is composed of m keys and n values, m and n are both positive integers greater than or equal to 1; The content of the Data must contain start and end, the value of the start is the starting table row of the data, and the value of the end is the ending table row of the data; The content of the Filter has at least one, the key of the Filter is the column name of the table, and the value of the Filter is a filter condition function, the format of the filter condition function is: function name (parameter), the number of parameters is greater than or equal to 0, if there are multiple parameters, the parameters are separated by English commas; The content of the Order has at least one, the key of the Order is the column name of the table, and the value of the Order is ASC or DESC, the ASC represents the order, and the DESC represents the reverse order; S34: parse the custom script string in INI format to generate a data processing instruction object; S341: parse the configuration script, use the INI file parser to parse the configuration script, and extract the key-value pair mapping relationship corresponding to each configuration section; S342: build data range information, obtain the values corresponding to start and end from the Data section, convert the obtained values to integer type, and reduce 1 to the index according to the preset index adjustment rule to adapt to zero-based index, generate data range information, and encapsulate it as a data range object; S343: build a sorting rule set, traverse all key-value pairs in the Order section; take the key as the sorting field name, and take the value as the sorting type; encapsulate the sorting field name and the sorting type as a sorting rule object, and add all the sorting rule objects to the sorting rule set. S344: Constructing the filter rule set, traversing all key-value pairs in the Filter section; taking the key as the filter field name; applying a predefined regular expression to the value string for pattern matching, which is used to identify the string in the format of "function name (parameter 1, parameter 2,... )"; if the matching is successful, extracting the function name and the parameter list, encapsulating the filter field name, the function name and the parameter list into a filter rule object, and adding the filter rule object meeting the condition to the filter rule set; S345: Generating the instruction object, creating a data processing instruction object, setting the data range object generated in step S342, the sorting rule set generated in step S343 and the filter rule set generated in step S344 into the data processing instruction object respectively, and returning the data processing instruction object; S4: Preparing the data to be filtered in the Table table object; S41: If the attribute data range object of the data processing instruction object is not empty, then executing the next step, otherwise ending; S42: According to the start and end in the data range object, traversing the Table table object; S43: If the row number of the table row is within the range of start and end, then storing the data of all cells of the qualified row into the Map set, the key of Map being the column name of the table and the value being the value of the cell of the table row, storing the Map set into the List set named prepareData, if not qualified then skipping the table row; S5: Filtering the data; S51: If the attribute filter rule set of the data processing instruction object is not empty, then executing step S52, otherwise executing step S6; S52: Traversing each filter rule object in the filter rule set; S53: Traversing each element in prepareData; S54: According to the function name attribute of the filter rule object, finding the corresponding filter function from the global configuration, inputting the parameter list of the filter rule object, and executing the Filter method of the function for judgment; S55: If the judgment is true, then retaining the data and storing the data into the List set named filterData, the elements of the set being Map; S56: If the judgment is false, then discarding the data; S6: Sorting the data; S61: If the attribute sorting rule set of the data processing instruction object is not empty, then executing step S62, otherwise executing step S7; S62: create a sorting comparator according to the sorting rule set; S63: sort the data of filterData by the sorting comparator; S7: replace the data in the Table table object; S71: according to the start in the attribute data range object of the data processing instruction object, start from the start row of the Table table object, and end at the row number of the element number of filterData + start, loop through each row of the Table table object; S72: loop through each cell of the table row, and according to the row and column name where the cell is located, obtain the corresponding data from filterData and replace the data in the cell; S8: delete the redundant table rows in the Table table object; S81: according to the start in the attribute data range object of the data processing instruction object and the element number of filterData, determine the starting row to be deleted; S82: according to the end in the attribute data range object of the data processing instruction object and the element number of filterData, determine the end row to be deleted; S83: loop through each row of the table, if the table row is between the starting row to be deleted and the end row to be deleted, delete the row; S9: the PPT object generates a new PPT file and returns the result; S91: the PPT object generates a new PPT file; S92: the new PPT file is returned to the user.

[0005] Preferably, in step S1, the PPT file is a file complete path, a file input stream object, a file object or a file byte array; in step S9, the new PPT file is a byte stream, a file complete path, a file object or a file output stream object.

[0006] Preferably, in step S3, the setting position of the conditional format script is: located in the table - right-click to set shape format - optional text - description, and the description is the description attribute of the optional text in the XML object of the Table table object; the table row and column position definition specification: the first column of the table is A column, the second column is B column, and so on, and the first row of the table is 1, the second row is 2, and so on.

[0007] Compared with the prior art, the present application has the beneficial effects that: the present application is based on a self-defined format script, performs corresponding data filtering and data sorting operations by analyzing the script, replaces the filtered data into a PPT table, deletes the redundant PPT table rows, completes the sorting and filtering of the data in the PPT table, and realizes the sorting and filtering function of the PPT table; without writing codes, only by filling in the script in the "optional text" of the PPT table in the INI format, the data filtering and sorting can be realized, the filtering condition function can be expanded by the user, the user can filter and sort the data in the table according to different needs, and the operation is convenient; the redundant table rows in the Table table object are deleted to ensure that the data amount after processing is completely consistent with the number of rows in the original processing range, avoid the residual redundant old data in the data range after processing, and ensure that the table only retains the effective data. BRIEF DESCRIPTION OF DRAWINGS

[0008] Figure 1 The flow chart of the method for realizing the sorting and filtering function of the PPT table of the present application. DETAILED DESCRIPTION

[0009] In order to further understand the purpose, structure, features and functions of the present application, the following detailed description is provided in conjunction with the embodiments. Embodiment 1

[0010] Please refer to Figure 1 The present application provides a method for realizing the sorting and filtering function of the PPT table, which comprises the following steps: S1: receiving the PPT file input by the user to create a PPT object; S11: receiving the PPT file input by the user, wherein the PPT file is a file complete path, a file input stream object, a file object or a file byte array; S12: checking whether the PPT file is null, when the PPT file is null, the checking is not passed, then returning an error message and ending, when the PPT file is a file complete path, a file input stream object, a file object or a file byte array, the checking is passed, then entering step S13; S13: creating the PPT file into a file stream object, creating the file stream object into a buffer stream object, and creating the buffer stream object into a PPT object; S2: looping through the Table table object in the PPT object and putting it into a List collection named tableList; S21: looping through the Slide slide object in the PPT object; S22: looping through the Shape shape object in the Slide slide object; S23: judging whether the Shape shape object is a Table table object by the instanceof keyword, if yes, the Shape shape object is forcibly converted into a Table table object and stored in the List collection named tableList, if not, skipping and continuing to execute S22 until the end of the iteration; S3: reading the script in the custom format of the Table table object to generate a data processing instruction object; S31: obtaining the number of elements by the size() method of the List collection, judging whether the number of elements in the List collection tableList is 0, if yes, ending the rendering, if not, continuing to the next step; S32: looping through each element Table table object in the List collection tableList; S33: locating the optional text description attribute in the XML object of the Table table object by the path syntax of xml to read the value of the description, i.e. the custom script string; The setting position of the conditional format script: located in the table - right-click to set the shape format - optional text - description, the description is the description attribute of the optional text in the XML object of the Table table object; The definition specification of the table row and column position: the first column of the table is A column, the second column is B column, and so on, the first row of the table is 1, the second row is 2, and so on; The custom script is in INI format, and the custom script is composed of sections, keys and values; The section must contain Data, and also contains Filter and / or Order; The content of the section is composed of m keys and n values, m and n are both positive integers greater than or equal to 1; The content of the Data must contain start and end, the value of the start is the starting table row of the data, and the value of the end is the ending table row of the data; The content of the Filter has at least one, the key of the Filter is the column name of the table, and the value of the Filter is a filter condition function, the filter condition function format is: function name (parameter), the number of parameters is greater than or equal to 0, if there are multiple parameters, the parameters are separated by English commas; The content of the Order has at least one, the key of the Order is the column name of the table, and the value of the Order is ASC or DESC, the ASC represents the order, and the DESC represents the reverse order; S34: analyzing the custom script string in INI format to generate a data processing instruction object; S341: Analyze the configuration script, parse the configuration script using an INI file parser, and extract the key-value pair mapping relationship corresponding to each configuration section; S342: Build data range information, obtain the values corresponding to start and end from the Data section, convert the obtained values to integer type, and reduce the index by 1 according to the preset index adjustment rule to adapt to zero-based indexing, generate data range information, and encapsulate it as a data range object; S343: Build a sorting rule set, traverse all key-value pairs in the Order section; take the key as the sorting field name and the value as the sorting type; encapsulate the sorting field name and the sorting type as a sorting rule object, and add all sorting rule objects to the sorting rule set; S344: Build a filter rule set, traverse all key-value pairs in the Filter section; take the key as the filter field name; apply a predefined regular expression to the value string for pattern matching, the regular expression is used to identify the "function name (parameter1, parameter2,...)" format string; if the matching is successful, extract the function name and parameter list, encapsulate the filter field name, function name and parameter list as a filter rule object, and add the filter rule object that meets the condition to the filter rule set; S345: Generate an instruction object, create a data processing instruction object, set the data range object generated in step S342, the sorting rule set generated in step S343, and the filter rule set generated in step S344 to the data processing instruction object respectively, and return the data processing instruction object; S4: Prepare the data to be filtered in the Table object; S41: If the attribute data range object of the data processing instruction object is not empty, execute the next step, otherwise end; S42: According to start and end in the data range object, loop through the Table object; S43: If the row number of the table row is within the range of start and end, store the data of all cells of the matched row in the Map set, the key of Map is the column name of the table, and the value is the value of the cell of the table row, and store the Map set in the List set named prepareData, if it does not meet the condition, skip the table row; S5: Filter data; S51: If the attribute filter rule set of the data processing instruction object is not empty, execute step S52, otherwise execute step S6; S52: Traverse each filter rule object in the filter rule set; S53: Loop through each element in prepareData; S54: Find the corresponding filter function from the global configuration according to the function name attribute of the filter rule object, pass in the parameter list of the filter rule object, and execute the Filter method of the function to make a judgment; S55: If the judgment is true, the data is retained and stored in the List collection named filterData, and the elements of the collection are Map; S56: If the judgment is false, the data is discarded; S6: Sort the data; S61: If the sorting rule set of the data processing instruction object attribute is not empty, execute step S62, otherwise execute step S7; S62: Create a sorting comparator according to the sorting rule set; S63: Sort the data of filterData through the sorting comparator; S7: Replace the data in the Table table object; S71: According to the start in the data range object of the data processing instruction object attribute, start from the start row of the Table table object, and end at the row number of the element number of filterData+start, loop through each row of the Table table object; S72: Loop through each cell of the table row, and according to the row and column name where the cell is located, get the corresponding data from filterData and replace the data in the cell; S8: Delete the redundant table rows in the Table table object; S81: According to the start in the data range object of the data processing instruction object attribute and the element number of filterData, determine the starting row to be deleted; S82: According to the end in the data range object of the data processing instruction object attribute and the element number of filterData, determine the end row to be deleted; S83: Loop through each row of the table, if the table row is between the starting row to be deleted and the end row to be deleted, delete the row; S9: The PPT object generates a new PPT file and returns the result; S91: The PPT object generates a new PPT file, which is a byte stream, a file complete path, a file object, or a file output stream object; S92: Return the new PPT file to the user.

[0011] Based on the script of the custom format, by analyzing the script, performing corresponding data filtering and data sorting operations, and replacing the filtered data into the PPT table, deleting the redundant PPT table rows, completing the sorting and filtering of the data in the PPT table, realizing the sorting and filtering function of the PPT table; without writing code, only need to fill in the script in the "optional text" of the PPT table according to the INI format, can realize data filtering and sorting, support user to expand filtering condition function, user can filter and sort the data in the table according to different needs, convenient operation; delete the redundant table rows in the Table table object to ensure that the data quantity after processing is completely consistent with the number of rows in the original processing range, avoid residual redundant old data in the data range after processing, ensure that the table only retains valid data. Embodiment 2

[0012] Based on the method for realizing the sorting and filtering function of the PPT table in embodiment 1, the INI script is: [data] start=2 end=6 [order] C=DESC The following table is an example, Name Department Year of Entry Monthly Salary Zhang San Technical Department 2020 8000 Li Si Marketing Department 2019 7500 Wang Wu Technical Department 2021 9000 Zhao Liu Finance Department 2022 8500 Sun Qi Technical Department 2018 10000 Data extraction stage: according to the range of start=2 and end=6, extract the 2nd-6th row data from the original table, construct the prepareData list, including 5 complete records of Zhang San, Li Si, Wang Wu, Zhao Liu and Sun Qi; Filtering judgment stage: since the [Filter] section is not configured in the script, the filter rule set is empty, and the prepareData list is directly used as the filterData list; Sorting execution stage: according to the rule of C=DESC, create a sorting comparator, and sort the data in the filterData list in descending order according to "employment year"; the order after sorting is: Zhao Liu (2022) > Wang Wu (2021) > Zhang San (2020) > Li Si (2019) > Sun Qi (2018); Data backwriting stage: starting from the 2nd row (start=2) of the original table, write the 5 pieces of sorted data to the corresponding rows in turn; since the data quantity after processing (5 pieces) is completely consistent with the number of rows in the original processing range (5 pieces), there is no redundant row to delete, and the title row and table format remain unchanged.

[0013] The processed table is as follows: Name Department Year of Entry Monthly Salary Zhao Liu Finance Department 2022 8500 Wang Wu Technical Department 2021 9000 Zhang San Technical Department 2020 8000 Li Si Marketing Department 2019 7500 Sun Qi Technical Department 2018 10000 The present application has been described by the above-mentioned related embodiments, however, the above-mentioned embodiments are only examples for implementing the present application. It must be pointed out that the disclosed embodiments do not limit the scope of the present application. On the contrary, changes and modifications made without departing from the spirit and scope of the present application are within the scope of the patent protection of the present application.

Claims

1. A method for implementing PPT table supporting sorting and filtering functions, characterized in that: The method comprises the following steps: S1: receiving a PPT file input by a user, and creating a PPT object; S11: receiving a PPT file input by a user; S12: checking whether the PPT file is null, and returning an error message and ending when the checking fails, and entering step S13 when the PPT file is a file complete path, a file input stream object, a file object or a file byte array; S13: creating the PPT file into a file stream object, creating the file stream object into a buffer stream object, and creating the buffer stream object into a PPT object; S2: traversing Table objects in the PPT object in a loop and putting the Table objects into a List collection named tableList; S21: traversing Slide objects in the PPT object in a loop; S22: traversing Shape objects in the Slide object in a loop; S23: judging whether the Shape object is a Table object by using an instanceof keyword, and storing the Shape object into the List collection named tableList as a Table object if the Shape object is a Table object, or skipping and continuing to execute S22 until the traversal is completed if the Shape object is not a Table object; S3: reading a script in a custom format of the Table object, and generating a data processing instruction object; S31: obtaining the number of elements by using a size() method of the List collection, and judging whether the number of elements in the List collection tableList is 0, and ending if the number of elements is 0, or continuing to the next step if the number of elements is not 0; S32: traversing each element Table object in the List collection tableList in a loop; S33: finding an optional text explanation attribute in an XML object of the Table object by using an xml path syntax, and reading a value of the explanation, i.e., a custom script string; The custom script is in an INI format, and the custom script is composed of a section, a key and a value; The section must contain Data, and further contains Filter and / or Order; The content of the section is composed of m keys and n values, and m and n are both positive integers greater than or equal to 1; The content of the Data must contain start and end, the value of the start is a data starting table row, and the value of the end is a data ending table row; The content of the Filter has at least one, the key of the Filter is a column name of a table, and the value of the Filter is a filter condition function, the filter condition function is in a format of: function name (parameter), and the number of parameters is greater than or equal to 0, and if there are multiple parameters, the parameters are separated by English commas; The content of the Order has at least one, the key of the Order is a column name of a table, and the value of the Order is ASC or DESC, the ASC represents an order, and the DESC represents a reverse order; S34: parse the custom script string in INI format to generate a data processing instruction object; S341: parse the configuration script, use the INI file parser to parse the configuration script, and extract the key-value pair mapping relationship corresponding to each configuration section; S342: build data range information, obtain the values corresponding to start and end from the Data section, convert the obtained values to integer type, and reduce the index by 1 according to the preset index adjustment rule to adapt to zero-based index, generate data range information, and encapsulate it as a data range object; S343: build a sorting rule set, traverse all key-value pairs in the Order section; take the key as the sorting field name and the value as the sorting type; encapsulate the sorting field name and the sorting type as a sorting rule object, and add all sorting rule objects to the sorting rule set; S344: build a filter rule set, traverse all key-value pairs in the Filter section; take the key as the filter field name; apply a predefined regular expression to the value string for pattern matching, the regular expression is used to identify the "function name (argument1, argument2,...)" format string; if the matching is successful, extract the function name and the argument list, encapsulate the filter field name, the function name and the argument list as a filter rule object, and add the filter rule object that meets the condition to the filter rule set; S345: generate an instruction object, create a data processing instruction object, set the data range object generated in step S342, the sorting rule set generated in step S343, and the filter rule set generated in step S344 to the data processing instruction object respectively, and return the data processing instruction object; S4: prepare the data to be filtered in the Table table object; S41: if the data range object of the data processing instruction object is not empty, execute the next step, otherwise end; S42: according to the start and end in the data range object, loop through the Table table object; S43: if the row number of the table row is within the start and end range, store the data of all cells of the matched row in the Map set, the key of Map is the column name of the table, and the value is the value of the cell of the table row, store the Map set in the List set named prepareData, if it does not match, skip the table row; S5: filter data; S51: if the filter rule set of the data processing instruction object is not empty, execute step S52, otherwise execute step S6; S52: traverse each filter rule object in the filter rule set; S53: loop through each element in prepareData; S54: find the corresponding filter function from the global configuration according to the function name attribute of the filter rule object, input the argument list of the filter rule object, and execute the Filter method of the function to judge; S55: if the judgment is true, keep the data, and store the data in the List set named filterData, and the elements of the set are Maps; S56: If the judgment is false, discard the data; S6: Sort the data; S61: If the attribute sorting rule set of the data processing instruction object is not empty, execute step S62, otherwise execute step S7; S62: Create a sorting comparator according to the sorting rule set; S63: Sort the data of filterData through the sorting comparator; S7: Replace the data in the Table table object; S71: According to the start in the data range object of the attribute of the data processing instruction object, start from the start row of the Table table object, and end at the row number of the element number of filterData+start, loop through each row of the Table table object; S72: Loop through each cell of the table row, and according to the row and column name where the cell is located, obtain the corresponding data from filterData and replace the data in the cell; S8: Delete the redundant table rows in the Table table object; S81: According to the start in the data range object of the attribute of the data processing instruction object and the element number of filterData, determine the starting row to be deleted; S82: According to the end in the data range object of the attribute of the data processing instruction object and the element number of filterData, determine the ending row to be deleted; S83: Loop through each row of the table, and if the table row is between the starting row to be deleted and the ending row to be deleted, delete the row; S9: The PPT object generates a new PPT file and returns the result; S91: The PPT object generates a new PPT file; S92: Return the new PPT file to the user.

2. The method for implementing PPT table supporting sorting and filtering functions according to claim 1, wherein: In step S1, the PPT file is a file complete path, a file input stream object, a file object or a file byte array; in step S9, the new PPT file is a byte stream, a file complete path, a file object or a file output stream object.

3. The method for implementing PPT table supporting sorting and filtering functions according to claim 1, wherein: In step S3, the setting position of the conditional format script is: located in the table-right click to set the shape format-selectable text-description, the description is the description attribute of the selectable text in the XML object of the Table table object; the table row and column position definition specification: the first column of the table is A column, the second column is B column, and so on, the first row of the table is 1, the second row is 2, and so on.