Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Thu Jun 06, 2019 2:39 pm

Good morning,

I need to add a FieldDocVariable with modifiers.
For example:

{DOCVARIABLE [varName] \ @ "ddMMyyy"}

But I do not know how to add the modifiers part so that it works.

Thank you very much for your help,

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Fri Jun 07, 2019 6:42 am

Hello,

Thanks for your inquiry.
I tried to add a FieldDocVariable with modifiers likes "{DOCVARIABLE test \ @ "ddMMyyy"}" in Word using MS Word, an error had occurred. It seems that the behavior is not supported.
When I did the same try with Our Spire.Doc, it also failed. Our Spire.Doc follows the standard of MS Word. I am afaid it cannot be achieved by our Spire.Doc if MS Word doesn't the feature.
if I make some mistakes, please tell me.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Fri Jun 07, 2019 7:04 am

Thank you very much for your reply.
Is it possible to do this with a DOCPROPERTY?
In word it is allowed but I do not know how it is done with spire.

Thank you very much for your help!

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Fri Jun 07, 2019 9:27 am

Hi,

Thanks for your reply.
Could you please tell us which kind of properties you tried in Word? CreateTime? So that we could provide you with the corresponding code.
[img]001.png[/img]
Thank you in advance.

Sincerely,
Amy
E-iceblue support team
You do not have the required permissions to view the files attached to this post.
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Fri Jun 07, 2019 9:54 am

DocProperties_2.PNG
hello!

Thanks very much for your help.
Actually, I use customproperties.
First I create the properties and then I use them.

spireDoc.CustomDocumentProperties.Add(varName, strValue);
spireDoc.Section[0].Paragraphs[0].AppendField(varName, FieldType.FieldDocProperty);
This works perfectly.

In word I can format the property and it also works.
See attachment DocProperties_1
DocProperties_1.PNG


Later I can configure the field.
See attachmen DocProperties_2
DocProperties_2.PNG


I see the result in my code.
See attachmen DocProperties_3.

DocProperties_3.PNG



But I don't know how I can make that in c# with spire.

I can only create fields without modifiers.
spireDoc.Section[0].Paragraphs[0].AppendField(varName, FieldType.FieldDocProperty);


Is there any way to create fields and add modifiers?

Thank you!
You do not have the required permissions to view the files attached to this post.

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Mon Jun 10, 2019 7:08 am

Hi,

Thanks for sharing further information. That is really helpful.
You could use Spire.Doc to create the DocProperty fields with modifiers.
Please refer to the following code snippet.
Code: Select all
 Document document = new Document();
            Section section = document.AddSection();
            document.CustomDocumentProperties.Add("value1", "AbCd");
            Field field = section.AddParagraph().AppendField("value1", FieldType.FieldDocProperty);
            field.Code = " DOCPROPERTY  value1 \\* upper";
            document.CustomDocumentProperties.Add("value2", "AbcD");
            field = section.AddParagraph().AppendField("value2", FieldType.FieldDocProperty);
            field.Code = " DOCPROPERTY  value2 \\* lower";
            document.IsUpdateFields = true;
            string result = "result.docx";
            document.SaveToFile(result, FileFormat.Docx2013);

But when executing document.IsUpdateFields = true to update the value of fields, I found the result update failed. I have forwarded the issue to our development team for further investigating. We will keep you updated.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 10, 2019 7:36 am

Tthank you very much for your help.
When they solve the problem let me know.
Many thanks!

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Mon Jun 10, 2019 7:47 am

Hi,

It's my pleasure.
I'm sure I'll tell you when there is any update.
Wish you all the best!

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Wed Jun 26, 2019 12:38 pm

Hello!

Have you been able to look at anything regarding this functionality? Do you know if they will include this functionality in any version of Spire?

Thank you very much!

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Thu Jun 27, 2019 1:15 am

Hi,

Thanks for following up.
I just got an update from our development. The issue has been fixed. The new version is under testing now.
We will tell you once new version is available.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Thu Jun 27, 2019 10:35 am

Hello!
Fantastic. I am very interested in this functionality and I thank you very much for your help.
Thank you very much!

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Fri Jun 28, 2019 1:58 am

Hi,

It's my pleasure.
We will inform you when new version is released.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Fri Jun 28, 2019 11:00 am

Hi,

The new version has been released. Please download and test Spire.Doc Pack(hot fix) Version:7.6.16.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Mon Jul 01, 2019 1:46 pm

Thanks!! :D A great job!

LauraNM
 
Posts: 58
Joined: Tue Feb 19, 2019 1:23 pm

Tue Jul 02, 2019 1:36 am

Hi,

You are welcome.
Looking forward to your feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2470
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc