简体   繁体   English

如何使用 Java 使 MPXJ-Library 在 mpp 文件中显示工作列

[英]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.我正在做一个内部项目,在 Java 中,我必须在其中读取一个 Excel 并将其解析为一个 mpp 分别是一个 MS Project compatible.xml 文件。 I'm creating the file and everythings working fine.我正在创建文件,一切正常。 But i want to show the columns "Work" and "ID" by default.但我想默认显示“工作”和“ID”列。

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.我可以在 MS Projects 中显示它们,并且值与我期望的一样,但我必须 select 并显示它们。 Is there a possibility to show them by default when you open the.xml file?打开 .xml 文件时是否可以默认显示它们?

I tried a lot and searched:我尝试了很多并搜索:

as well as StackOverflow.以及 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.这是我填写我的 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亲切的问候

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.不幸的是,使用 MPP 文件是您在 Microsoft Project 打开时自动指定日程表视觉外观的唯一方法。

You have a few options:你有几个选择:

  • I believe Aspose.Tasks can generate MPP files, so it may be that as part of that you can configure the layout you want我相信Aspose.Tasks可以生成 MPP 文件,所以它可能是你可以配置你想要的布局的一部分
  • As you are already working with Excel you may want to consider using VBA which would allow you to both extract the data you need from Excel, populate the schedule in MS Project and configure the layout of the schedule.由于您已经在使用 Excel,因此您可能需要考虑使用 VBA,这样您就可以从 Excel 中提取所需的数据,在 MS Project 中填充计划并配置计划的布局。
  • Finally, if you want to use MPXJ, when you generate the MSPDI file and import it into Microsoft Project you are given some options about how the file is opened (as a new schedule, append to an existing schedule, update an existing schedule).最后,如果您想使用 MPXJ,当您生成 MSPDI 文件并将其导入 Microsoft Project 时,您会看到一些关于如何打开文件的选项(作为新计划,append 到现有计划,更新现有计划)。 If you create an empty "template" MPP file with the visual layout you require, using the append or update options when you open the XML file and selecting the template file as the target should give you a finished file using the data you've generated with the visual layout you need.如果您使用所需的视觉布局创建一个空的“模板”MPP 文件,则在打开 XML 文件并选择模板文件作为目标时使用 append 或更新选项应该会使用您生成的数据为您提供完成的文件使用您需要的视觉布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM