Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Docx4j每下一页重复一次表格标题_Java_Docx4j - Fatal编程技术网

Java Docx4j每下一页重复一次表格标题

Java Docx4j每下一页重复一次表格标题,java,docx4j,Java,Docx4j,我使用Docx4j库根据所选的模式和数据创建文档。基本函数如下所述。 这似乎是可行的,但如果我的表占用了多个页面,我希望标题可以重复。我尝试了word中的“重复标题行”选项,但似乎无法正常工作。 也许我应该解包docx并挖掘xml文件,但我应该寻找什么呢 提前谢谢 public ResponseEntity<byte[]> fillDocument(@RequestBody String json, @PathVariable Long id) throws Exception {

我使用Docx4j库根据所选的模式和数据创建文档。基本函数如下所述。 这似乎是可行的,但如果我的表占用了多个页面,我希望标题可以重复。我尝试了word中的“重复标题行”选项,但似乎无法正常工作。 也许我应该解包docx并挖掘xml文件,但我应该寻找什么呢

提前谢谢

public ResponseEntity<byte[]> fillDocument(@RequestBody String json, @PathVariable Long id) throws Exception {

    DocumentSchemaDTO documentSchema = documentSchemaService.findOne(id).get();

    String xmlStream = documentSchemaService.jsonToXmlClean(json);

    InputStream inputStream = new ByteArrayInputStream(documentSchema.getFile());
    OutputStream out = new ByteArrayOutputStream();

    WordprocessingMLPackage wordMLPackage = Docx4J.load(inputStream);
    Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_BIND_INSERT_XML | Docx4J.FLAG_BIND_BIND_XML);
    Docx4jProperties.setProperty("docx4j.toc.BookmarksIntegrity.remediate", true);

    Docx4J.save(wordMLPackage, out, Docx4J.FLAG_NONE);
    byte[] document = ((ByteArrayOutputStream) out).toByteArray();

    GeneratedDocumentDTO generatedDocument = new GeneratedDocumentDTO();
    generatedDocument.setFile(document);
    generatedDocument.setName("Dokument: "+documentSchema.getName()+" "+ LocalDateTime.now());
    generatedDocument.setDocumentSchemaId(documentSchema.getId());
    generatedDocument.setCreatedDate(LocalDate.now());
    generatedDocumentService.save(generatedDocument);

    HttpHeaders headers = new HttpHeaders();
    headers.setContentDispositionFormData("filename", "Dokument");
    final ResponseEntity<byte[]> responseEntity = new ResponseEntity<>(document, headers, HttpStatus.OK);
    return  responseEntity;
}
public ResponseEntity fillDocument(@RequestBody String json,@PathVariable Long id)引发异常{
DocumentSchemaDTO documentSchema=documentSchemaService.findOne(id.get();
字符串xmlStream=documentSchemaService.jsonToXmlClean(json);
InputStream InputStream=new ByteArrayInputStream(documentSchema.getFile());
OutputStream out=新的ByteArrayOutputStream();
WordprocessingMLPackage wordMLPackage=Docx4J.load(inputStream);
Docx4J.bind(wordMLPackage,xmlStream,Docx4J.FLAG_bind_INSERT_XML | Docx4J.FLAG_bind_XML);
Docx4jProperties.setProperty(“docx4j.toc.BookmarksIntegrity.remediate”,true);
Docx4J.save(wordMLPackage,out,Docx4J.FLAG_NONE);
字节[]文档=((ByteArrayOutputStream)out).toByteArray();
GeneratedDocumentDTO generatedDocument=新生成的DocumentDTO();
generatedDocument.setFile(文档);
generatedDocument.setName(“Dokument:+documentSchema.getName()+”“+LocalDateTime.now());
generatedDocument.setDocumentSchemaId(documentSchema.getId());
setCreatedDate(LocalDate.now());
generatedDocumentService.save(generatedDocument);
HttpHeaders=新的HttpHeaders();
setContentDispositionFormData(“文件名”、“文件名”);
final ResponseEntity ResponseEntity=新的ResponseEntity(文档、标题、HttpStatus.OK);
返回响应性;
}