Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jul 16, 2019 6:40 am

Good morning,

Two issues:
  1.- Could you send me an example of use modifying adding modifiers to a DOCVARIABLE please?
I want to add a variable with modifiers but I do not know how to do it.
for me is similar use variables or doc properties. Any sample is good for me.

2.- Some case, I can't see all the definition of the property in de Code.
I'm doing tests but, the fact is that in the CODE I do not see all the value but, I can not access the formattingString property because it is private. (View image)
How can I get this formatting String?
docproperties.PNG


and change the modifier of a certain property?

I attach the document. --> SpireProperties.docx
moreproperties.PNG


 

Thank you very much for your help!!
Last edited by LauraNM on Tue Jul 16, 2019 10:10 am, edited 1 time in total.

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

Tue Jul 16, 2019 9:56 am

Hi,

Thanks for your inquiry.
1. Your license has expired, so that it is not valid for the latest Spire.Doc. For your case, I suggest that you contact our sales team (sales@e-iceblue.com) to renew your license.
2. There are three tables in your word document, and none of them have title or description. If I manually add title and description for them, then use our latest Spire.Doc (Spire.Doc Pack(hot fix) Version:7.6.16) to get the title and description, the values could be returned successfully. If you were not testing the word document you attached, could you please provide the document which could reproduce the "the Title and TableDescription property have no value" issue to help me further investigate it? Thanks in advance.
3. Do you want to modify the modifiers of DOCPROPERTY? Sorry it is not available to change it at present. And I did notice that the code of the field whose value is pieceDescription could not be obtained correctly. These issues have been posted to our Dev team for investigating and fixing. If there is any good news, I will inform you. Apologize for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Tue Jul 16, 2019 12:27 pm

Hello,

And it is possible create a new DOCPROPERTY with modifiers? Could you send me an example of use modifying adding modifiers to a DOCPROPERTY please?
I want to add a property with modifiers but I do not know how to do it.
Any sample is good for me.

Is possible to get the value of m_formattingString of the field object?

Thanks you very much!

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

Wed Jul 17, 2019 6:28 am

Hi,

Thanks for your feedback.
Please download the latest Spire.Doc Pack(hot fix) Version:7.6.16 and refer to the following code to create a new DOCPROPERTY with modifiers.
Code: Select all
Document document = new Document();
document.LoadFromFile("SpireProperties.Docx");
Section section = document.Sections[0];
document.CustomDocumentProperties.Add("newField", "newValue");
Field field = section.AddParagraph().AppendField("newField", FieldType.FieldDocProperty);
field.Code = " DOCPROPERTY  newField \\* upper";
document.IsUpdateFields = true;
string result = "result.docx";
document.SaveToFile(result, FileFormat.Docx2013);

Sorry the formattingString property has not been published yet, hence it is not available to get the value at present. I have already posted your requirement to our Dev team, they will investigate it. If the property is published or there is any update for you, I will let you know.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Wed Jul 17, 2019 7:32 am

fantastic! I'm going to try it! thank you!

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

Wed Jul 17, 2019 1:02 pm

Hello!

I am testing the new functionalyty
My code is the next:

Document document = new Document();
Section section = document.AddSection();
document.CustomDocumentProperties.Add("newField", "newValue");
Field field = section.AddParagraph().AppendField("newField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newField \* upper";


document.CustomDocumentProperties.Add("newDataField", "02/05/2019");
field = section.AddParagraph().AppendField("newDataField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newDataField \@ ""dddd, MMMM d, yyyy""";

document.CustomDocumentProperties.Add("newMoneyField", "12,56");
field = section.AddParagraph().AppendField("newMoneyField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newMoneyField \# ""0,00€""";

Section section2 = document.AddSection();
document.Variables.Add("varNewField", "newValue");
field = section2.AddParagraph().AppendField("varNewField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varNewField \* upper";


document.Variables.Add("varDataField", "02/05/2019");
field = section2.AddParagraph().AppendField("varDataField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varDataField \@ ""dddd, MMMM d, yyyy""";

document.Variables.Add("varMoneyField", "12,56");
field = section2.AddParagraph().AppendField("varMoneyField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varMoneyField \# ""0,00€""";


document.IsUpdateFields = true;
string result = @"D:\temp\Result.docx";
document.SaveToFile(result, Spire.Doc.FileFormat.Docx2013);

I have been testing the new operation.
Both with the variables and with the properties, if the modifier is numeric, it is necessary to update the fields so that the result is correct. Otherwise, if what I do is convert the doc to pdf without opening it and updating it, the result is incorrect.

The error occurs mainly with the number modifiers.

In the DOCVARIABLES, regardless of the type of modifier I need to open the doc and give it to update fields to make it work.

Am I doing something wrong?

Thank you!!

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

Thu Jul 18, 2019 9:30 am

Hi,

Thanks for your feedback.
I tested your code and found that the Property field and Variable field with number modifiers could not be updated correctly. Could you please provide your correct result as well as the error result to help us better investigate your issue? Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu Jul 18, 2019 2:19 pm

Hello!

Of course!! The test is very easy.
Generate word. Open file. you can see the error. Then, select all content into the document, (Ctrl+E) --> Right button --> update fields! and then you can see the correct result.

FieldsResult.png


Thank you very much!

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

Fri Jul 19, 2019 3:27 am

Hi,

Thanks for your confirmation.
I noticed the same issue as yours. The issue has already been logged into our bug tracking system. If it is fixed or there is any update, I will let you know.
Apologize for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Fri Jul 19, 2019 6:53 am

Thanks you very much!

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

Return to Spire.Doc