Code Monkey home page Code Monkey logo

Comments (5)

AlexNosk avatar AlexNosk commented on June 9, 2024

@jeremyliu17 图片或表格阳离子作为简单文本和带有适当标签的 SEQ 字段插入。 所以你可以使用这样的代码:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.write("Table ");
builder.insertField("SEQ Table");
        
doc.save("C:\\Temp\\out.docx");

from aspose.words-for-java.

jeremyliu17 avatar jeremyliu17 commented on June 9, 2024

@jeremyliu17 图片或表格阳离子作为简单文本和带有适当标签的 SEQ 字段插入。 所以你可以使用这样的代码:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.write("Table ");
builder.insertField("SEQ Table");
        
doc.save("C:\\Temp\\out.docx");

非常感谢,这样能够生成表1,表2...连续的序列,如果想生成这种形式表1-1,表1-2,第一个1表示跟随章节标题去变化,第二个数字为表的顺序,这种有好的办法解决吗
企业微信截图_20240411142646

from aspose.words-for-java.

AlexNosk avatar AlexNosk commented on June 9, 2024

@jeremyliu17 如果可能的话,您能否使用 MS Word 创建预期的输出并附在此处供我们参考? 通过截图很难看出文档中使用了哪些字段。

from aspose.words-for-java.

jeremyliu17 avatar jeremyliu17 commented on June 9, 2024

期望输出.docx

@jeremyliu17 如果可能的话,您能否使用 MS Word 创建预期的输出并附在此处供我们参考? 通过截图很难看出文档中使用了哪些字段。

期望输出.docx
最终想生成一个这样的文档,不同测试类型的标题,和里面的表标题及表内容,希望实现的效果,我加在文档批注中了,希望得到您的回复

from aspose.words-for-java.

AlexNosk avatar AlexNosk commented on June 9, 2024

@jeremyliu17 感谢您提供更多信息。 在表格标题中有“STYLEREF”和“SEQ”字段:
image

因此,您应该插入两者以获得所需的输出:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
    
doc.getStyles().getByStyleIdentifier(StyleIdentifier.HEADING_1).getListFormat().applyNumberDefault();
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("This is some styled paragraph");
builder.getParagraphFormat().clearFormatting();
        
builder.write("Table ");
builder.insertField("STYLEREF \"Heading 1\" \\s");
builder.write("-");
builder.insertField("SEQ Table");
builder.write(" Some table caption");
    
doc.save("C:\\Temp\\out.docx");

from aspose.words-for-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.