Use the Docx open Source component for Dynamic Data filling.

Source: Internet
Author: User

1, first explain, what is called Dynamic Data, Dynamic Data refers to the format of a piece of data fixed, but the number of data is not fixed.

2, the application environment, in a table if, now the table has three rows n columns, if you need to add the same size row or n rows after the first row of the table, how should you do?

3, according to the above application environment, it is not difficult to find, to complete the work of 5 processes, 1, find location. 2. Get the template line. 3. Add the template line to the next line in the current row. 4. Write the value to the added line. There may be a loop procedure 5, delete the template line.

4, words not much said, on the code.

Note: To use this fragment, first add a reference to the Docx component.

Docx Project: http://docx.codeplex.com/releases/view/80870

Controls the number of rows to insert for                (int i = 0; i < 5; i++)                {/                    /here                    the test succeeds//Gets the object to the template row (typically a blank line, only the shelf has no data)                    row InsertRow = d Ocx. Tables[0]. ROWS[26];                    Will get to this one template row, added to the next row of the current row (the next node)                    //I am here to insert into the 27th row and later, my template row is the 27th row, I is the role of the control is the row of the operation of the                    docx. Tables[0]. Rows[26+i]. Xml.addafterself (insertrow.xml);                                        Control to insert those columns                    for (int j = 2; J < 9; j + +)                    {                        //Set the value to insert                        string value = (i + j). ToString ();                        Adds a value to the cell                        docx. Tables[0]. rows[26 + i + 1]. CELLS[J]. Paragraphs[0]. Append (value);                    }                     Paragraph.Xml.ElementsBeforeSelf ();                }                Delete the template line, or there will be a blank line                docx. Tables[0]. Removerow (26);

  

The

uses the Docx open source component for Dynamic Data filling.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.