Hi, we are evaluating Aspose libraries for integration into a cloud solution. Our goal is to download MS Office files from the cloud and set some custom properties into the files before sending them to the downloading user. The question right now is, if it’s possible to add custom properties to e.g. an Excel file and save it without changing the last modified date/user. Can you answer this? Thanks in advance.
Your query has two parts:
- Setting customer properties.
- Saving document without changing last modified user or date information.
Answer to 1:
Yes, you can add custom properties to Word, Excel and Power point documents. For details, please visit the link:
- Working with Word Document Properties
- Managing Excel Document Properties
- Adding Custom Properties visible inside Excel Document Information Panel
- Managing Slides Document Properties
Answer to 2:
In case of MS Power Point document, support for preserving the the last modified date/time and user information on adding or changing custom document property is available. We have logged a request for this feature into our system with ID SLIDESNET-40262. We will update you here once there is some information or a fix version available in this regard.
In case of MS Excel document, Aspose.Cells exposes two properties to store the user and date information of last modification. These properties can be used to read and set the values.
You can set your desired last modified Date/Time and saved by information before saving the Excel file. Sample code snippet is given below:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("sample-document-properties.xlsx"); Aspose.Cells.Properties.BuiltInDocumentPropertyCollection docproperties = workbook.Worksheets.BuiltInDocumentProperties; docproperties.LastSavedBy = "......."; docproperties.LastSavedTime = DateTime.Now;
Hope the above information helps. Feel free to contact us in case of any query or comments.
For following request concerning to Aspose.Slides, I suggest you to please try using below sample code.
string sourcePath = path + "source.pptx"; string destPath = path + "dest.pptx"; Presentation presentation = new Presentation(sourcePath); var tempLastSavedTime = presentation.DocumentProperties.LastSavedTime; // preserving source presentation LastSavedTime // Presentation editing and saving presentation.Slides.RemoveAt(0); // for example remove slide presentation.Save(destPath, SaveFormat.Pptx); // Read and correct saved presentation properties IPresentationInfo pInfo = PresentationFactory.Instance.GetPresentationInfo(destPath); IDocumentProperties docProps = pInfo.ReadDocumentProperties(); docProps.LastSavedTime = tempLastSavedTime; // restore source LastSavedTime value docProps.LastSavedBy = "Changed"; // change LastSavedBy user name pInfo.UpdateDocumentProperties(docProps); pInfo.WriteBindedPresentation(destPath);
The issues you have found earlier (filed as SLIDESNET-40262) have been fixed in this update.