close messageThis website uses 'cookies', both our own as well as from third parties, to provide a better experience and service. When browsing our website or using our services you agree to our use of 'cookies'. For more information, see our Privacy policy.

deleteTemplateBlock

deleteTemplateBlock

BASIC / ADVANCED / PREMIUM

Deletes a block of content from the Word template.

Description
public void deleteTemplateBlock(String blockName)

The BLOCK variables are wrappers of content. They are used to remove unwanted parts of the document on “run time”.

This method does exactly that: removes a block of content from the Word template that has been previously enclosed between BLOCK tags ($BLOCK_varName$).

Parameters

blockName

The name of the block placeholder.

Code samples

Example #1

x
 
1
package examples.Templates.deleteTemplateBlock;
2
3
import com.javadocx.CreateDocxFromTemplate;
4
5
public class Sample1 {
6
    public static void main(String[] args) throws Exception {
7
        CreateDocxFromTemplate docx = new CreateDocxFromTemplate("src/examples/files/TemplateBlocks.docx");
8
        
9
        docx.deleteTemplateBlock("FIRST");
10
        
11
        docx.createDocx("example_deleteTemplateBlock_1");
12
    }
13
}
14

The resulting Word document looks like:

­
­