javaxmlms-projectmpxj

How to make MPXJ-Library show work column in mpp File using Java


I'm doing an internal Project, in Java, where i have to read an Excel and Parse it into a mpp respectively a MS Project compatible .xml file. I'm creating the file and everythings working fine. But i want to show the columns "Work" and "ID" by default.

I can show them in MS Projects and the values are as I expect them to be, but i have to select and show them. Is there a possibility to show them by default when you open the .xml file?

I tried a lot and searched:

as well as StackOverflow. But i didn't found any Information helping me out or it wasn't helpful cause methods changed and i didn't found the equivalent new ones.

this is where i fill the tasks and resources of my mpp.

if (!extractedRow.getElement().isEmpty())
            {
                element = contract.addTask();
                element.setName(extractedRow.getElement());
                element.setStart(startingDate);
                element.setOutlineLevel(LookUp.Mpp_Conversion_Element_OutlineLevel());
                element.setID(id++);

            }
            else if (!extractedRow.getWorkpackage().isEmpty())
            {
                workpackage = Objects.requireNonNull(element).addTask();
                workpackage.setName(extractedRow.getWorkpackage());
                workpackage.setOutlineLevel(LookUp.Mpp_Conversion_Workpackage_OutlineLevel());
                workpackage.setID(id++);

            }
            else if (!extractedRow.getTask().isEmpty())
            {
                task = Objects.requireNonNull(workpackage).addTask();
                task.setName(extractedRow.getTask());
                task.setType(TaskType.FIXED_WORK);
                task.setOutlineLevel(LookUp.Mpp_Conversion_Task_OutlineLevel());
                task.setWork(Duration.getInstance(extractedRow.getEstimatedTime(), TimeUnit.HOURS));
                task.setDuration(Duration.getInstance(extractedRow.getEstimatedTime() / 8, TimeUnit.DAYS));
                task.setRemainingWork(Duration.getInstance(extractedRow.getEstimatedTime(), TimeUnit.HOURS));
                task.setID(id++);

                if (!extractedRow.getRole().isEmpty())
                {
                    for (Resource resource : _project.getResources())
                    {
                        if (resource.getName().equals(_filereader.get_mapper().getMapping(extractedRow.getRole())))
                        {
                            assn = Objects.requireNonNull(task).addResourceAssignment(resource);
                            assn.setStart(task.getStart());
                            assn.setWork(Duration.getInstance(extractedRow.getEstimatedTime(), TimeUnit.HOURS));
                        }
                    }
                }
            }

Kind Regards


Solution

  • Unfortunately using an MPP file is the only way for you to specify the visual appearance of a schedule automatically when it is opened by Microsoft Project.

    You have a few options: