StyleIdentifier.getName(StyleIdentifier.HEADING_1) == “HEADING_1”,but word is “标题1”
@Professionalize.Discourse The name obtained from StyleIdentifier.getName(StyleIdentifier.HEADING_1) is “HEADING_1”, but the word shows “标题 1”
document.getStyles().getByStyleIdentifier(StyleIdentifier.HEADING_1).setName("HEADING_1");
That’s okay, is there any other way?
@alexey.noskov I know, is there a way to get this name, and if I change it like this, it will affect the original field
@Crane I would suggest you to use StyleIdentifier
instead of style name for standard styles. Such way you will be sure the style is set correctly regardless of the consumer user interface language.
https://forum.aspose.com/t/solved-reference-to-heading-style-in-fields/59369
I found the answer here, but I can only write fileCode
, and the fileStyleRef
object doesn’t seem to be supported.
@Crane unfortunately, it is still not quite clear what you mean. You can insert STYLEREF
field using the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("Test heading");
builder.getParagraphFormat().clearFormatting();
FieldStyleRef styleRef = (FieldStyleRef)builder.insertField(FieldType.FIELD_STYLE_REF, false);
styleRef.setStyleName(doc.getStyles().getByStyleIdentifier(StyleIdentifier.HEADING_1).getName());
styleRef.update();
doc.save("C:\\Temp\\out.docx");
This is not good, my ms word
in Chinese.
style.Ref.setStyle(StyleIndentifier.HEADING_1),My understanding is that there should be such a method
Unfortunately, this is not possible, since Aspose.Words cannot guess what language will be used on tend user consumer application.
Is there a ‘builder’ way to generate a domain code instead of a string of strings.
eg: ref.add().add()
@Crane Could you please elaborate your requirements. Unfortunately, it is not quite clear what you mean.