C # process automatic report generation by Word. 3. design template,
Since it is a template, various tags and configurations are indispensable. The word bookmarks are mainly used here.
Press ctrl + shift + F5 to open the word bookmarks Function
For example
As shown in, you can select a region in word and press ctrl + shift + F5 to add a bookmarks for this section.
Is it understood that a pointer is added for this part of the area? According to the operations shown in the figure, you can identify some text and then find this part for operation.
In the first article, Mr. Luo talked about the main content completed this time. The following describes the implementation method. In order to identify the types of bookmarks and some key configurations, therefore, the naming format of bookmarks is agreed.
For example, it is only used to update text. The format is label _ Level _ name.
The loop here is for loop usage, which is often encountered in the report. It can be seen through the directory in this example.
Template:
Actual results
The student names are not fixed during the term, so the document level is defined here.
The most basic level of the document is 0, the cycle of the term is 1, the cycle of the term name is 2, and so on.
Because a loop exists, the dataset needs to be filtered according to the cycle conditions.
The label format of the loop is loop _ Level _. The number of tables in the Dataset is obtained (starting from 1) _ filter fields are separated by XX. (special characters other than underlines are not allowed here. Use XX.) _ loop name
1. Update the text at the specified position, as shown in. Replace the text in the tag with the text in the data source.
2. Tables are supported. -- this part was originally intended to add bookmarks to tables. later it was found that there was a table attribute, and it was better to write it here.
The title format is the same as loop
Optional. If you want to aggregate rows, You need to identify them. The summary or s: [total] rows are the rows of tables in the template, summaryfilter or sf: the condition that the dataset is further filtered to the summary row (because a table takes only one able and specifies which datarow is used as the total)
3. Supports charts.
It is configured in the chart title in the format of "chart _ Level _". The number of tables in Dataset is obtained (starting from 1) _ filter fields are separated by XX characters. (special characters other than underlines are not allowed here. Use this XX character) _ chart name_whether to use the columnName of the able as the first row _ starting from the column of the Datatable (column starting with 1) _ deadline Column
4. Support area content generation cyclically. -- the configuration method is described above, and the program will be processed recursively.
5. Directory. -- no need to identify. Add a directory to the template. After the content is processed, update the directory dynamically.