We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to read / write custom attribute in MPP file

Suppose I have created custom column saying RedmineIssueNumber in my MPP file.

How can I read this column from java code and how can I insert values in it from java code.

@ketaki2092,

Thank you for contacting Aspose support team.

You may please give a try to following sample code and refer to this link for more information.

// Create new project
Project project1 = new Project("Blank2010.mpp");

//1.    Adding Plain Text Attribute

//Create an Extended Attribute Definition of Text1 type
ExtendedAttributeDefinition taskExtendedAttributeText1Definition = ExtendedAttributeDefinition.createTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text1, "Task City Name");

//Add it to the project's Extended Attributes collection
project1.getExtendedAttributes().add(taskExtendedAttributeText1Definition);

//Add a task to the project
Task task = project1.getRootTask().getChildren().add("Task 1");

//Create an Extended Attribute from the Attribute Definition
ExtendedAttribute taskExtendedAttributeText1 = taskExtendedAttributeText1Definition.createExtendedAttribute();

//Assign a value to the generated Extended Attribute
taskExtendedAttributeText1.setValue("London");

//Add the Extended Attribute to task
task.getExtendedAttributes().add(taskExtendedAttributeText1);

project1.save("PlainTextExtendedAttribute_out.mpp", SaveFileFormat.MPP);

Project project = new Project("PlainTextExtendedAttribute_out.mpp");

for (Task tsk : project.getRootTask().getChildren())
{
    System.out.println(tsk.get(Tsk.NAME));
    for (ExtendedAttribute ea : tsk.getExtendedAttributes())
    {
        System.out.println(ea.getFieldId());
        System.out.println(ea.getValue());
    }
}

Thank you so much for your reply!