FieldSaveDate
Contents
[
Hide
]FieldSaveDate class
Implements the SAVEDATE field.
To learn more, visit the Working with Fields documentation article.
public class FieldSaveDate : Field
Constructors
Name | Description |
---|---|
FieldSaveDate() | The default constructor. |
Properties
Name | Description |
---|---|
DisplayResult { get; } | Gets the text that represents the displayed field result. |
End { get; } | Gets the node that represents the field end. |
Format { get; } | Gets a FieldFormat object that provides typed access to field’s formatting. |
IsDirty { get; set; } | Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. |
IsLocked { get; set; } | Gets or sets whether the field is locked (should not recalculate its result). |
LocaleId { get; set; } | Gets or sets the LCID of the field. |
Result { get; set; } | Gets or sets text that is between the field separator and field end. |
Separator { get; } | Gets the node that represents the field separator. Can be null . |
Start { get; } | Gets the node that represents the start of the field. |
virtual Type { get; } | Gets the Microsoft Word field type. |
UseLunarCalendar { get; set; } | Gets or sets whether to use the Hijri Lunar or Hebrew Lunar calendar. |
UseSakaEraCalendar { get; set; } | Gets or sets whether to use the Saka Era calendar. |
UseUmAlQuraCalendar { get; set; } | Gets or sets whether to use the Um-al-Qura calendar. |
Methods
Name | Description |
---|---|
GetFieldCode() | Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included. |
GetFieldCode(bool) | Returns text between field start and field separator (or field end if there is no separator). |
Remove() | Removes the field from the document. Returns a node right after the field. If the field’s end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null . |
Unlink() | Performs the field unlink. |
Update() | Performs the field update. Throws if the field is being updated already. |
Update(bool) | Performs a field update. Throws if the field is being updated already. |
Remarks
Retrieves the date and time on which the document was last saved. By default, the Gregorian calendar is used.
Examples
Shows how to use the SAVEDATE field to display the date/time of the document’s most recent save operation performed using Microsoft Word.
Document doc = new Document(MyDir + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.Writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.Write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate)builder.InsertField(FieldType.FieldSaveDate, true);
field.UseLunarCalendar = true;
Assert.AreEqual(" SAVEDATE \\h", field.GetFieldCode());
// 2 - Umm al-Qura calendar:
builder.Write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate)builder.InsertField(FieldType.FieldSaveDate, true);
field.UseUmAlQuraCalendar = true;
Assert.AreEqual(" SAVEDATE \\u", field.GetFieldCode());
// 3 - Indian National calendar:
builder.Write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate)builder.InsertField(FieldType.FieldSaveDate, true);
field.UseSakaEraCalendar = true;
Assert.AreEqual(" SAVEDATE \\s", field.GetFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.BuiltInDocumentProperties.LastSavedTime = DateTime.Now;
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.SAVEDATE.docx");
See Also
- class Field
- namespace Aspose.Words.Fields
- assembly Aspose.Words