1. 製品
  2.   Project Management
  3.   Java
  4.   Aspose.Tasks for Java

Aspose.Tasks for Java

 
 

Java Project Management API to Create & Convert Microsoft Project Files

The API allows to Create user-friendly Project Management Solutions to Read Project Data, Generate Reports & Export Project Data to PDF, XPS & Image Formats.

Aspose.Tasks for Java とは何ですか?

Effective Java Project Management requires the right tools, and Aspose.Tasks for Java delivers a powerful and user-friendly solution. This free Project Management library enables developers to manage project files, read project data, update tasks, and generate reports with minimal effort. Whether you're working with simple tasks or complex schedules, the API gives precise control over task dependencies, resources, and timelines. Its rich feature set allows you to handle project tasks in Java with accuracy, ensuring your applications maintain consistent and reliable data throughout the lifecycle of any project.

Aspose.Tasks empowers Java developers to create MPP using Java, convert MPP files, and even create MPX files in Java, making it a versatile tool for reading and writing Microsoft Project formats. The library supports key project formats like MPP, MPX, and XML, while also offering advanced capabilities such as task scheduling, resource allocation, and Gantt chart generation. These features make it ideal for developing applications that offer interactive and professional project planning experiences. With support for Project Data Conversion to PDF and seamless integration into Java apps, Aspose.Tasks is a top-tier choice for anyone seeking to build or enhance project management software.

Previous Next

Aspose.Tasks for Java の開始方法

The recommend way to install Aspose.Tasks for Java is via Maven repository. You can easily use Aspose.Words for Java API directly in your Maven Projects with simple configurations.

Aspose.Tasks for Java の Maven 依存関係

 //Define the Aspose.Tasks for Java API dependency in your pom.xml as follows
<dependencies>
	<dependency>
	<groupId>com.aspose</groupId>
	<artifactId>aspose-tasks</artifactId>
	<version>20.10</version>
	<classifier>jdk18</classifier>
	</dependency>
</dependencies>
Aspose.Tasks の リリースページ から直接ダウンロードできます。

Java で新しいプロジェクト ファイルを作成

Software Developers can create new empty projects from scratch using Aspose.Tasks for Java. This is useful when you need to generate project files dynamically. The Library supports a wide range of Microsoft Project file formats, including MPP, XML, and MPX. At present, Aspose.Tasks for Java provides the facility to create XML project files only. The following lines of code shows how software developers can create a simple project file in XML format.

Java アプリケーション内で空のプロジェクトを生成する方法

 
public class CreateEmptyProjectFile {
    public static void main(String[] args) {
        // ExStart: CreateEmptyProjectFile
        // For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
        // The path to the documents directory.
        String dataDir = Utils.getDataDir(CreateEmptyProjectFile.class);

        // Create a project instance
        Project newProject = new Project();

        newProject.save(dataDir + "project1.xml", SaveFileFormat.Xml);

        //Display result of conversion.
        System.out.println("Project file generated Successfully");
        // ExEnd: CreateEmptyProjectFile
    }
}

Java API を使用したプロジェクト ファイルの読み取り

One of the fundamental features of Aspose.Tasks for Java is the ability to read Microsoft Project files. The library allows software developers to load an existing project file with just a couple of lines of code and extract valuable information from project files. The Project class can be used to achieve this tasks, you need to provide path to MPP or XML document and returns a Project object which can be used to manipulate project data. The following example shows, how software developers can read a project file online inside Java applications.

Java API を使用してオンラインでプロジェクト ファイルを読み取る方法

 
String sharepointDomainAddress = "https://contoso.sharepoint.com";
String userName = "admin@contoso.onmicrosoft.com";
String password = "MyPassword";

ProjectServerCredentials credentials = new ProjectServerCredentials(sharepointDomainAddress, userName, password);
ProjectServerManager reader = new ProjectServerManager(credentials);

for (ProjectInfo p : (Iterable)reader.getProjectList())
{
    System.out.println("Project Name:" + p.getName());
    System.out.println("Project Created Date:" + p.getCreatedDate());
    System.out.println("Project Last Saved Date:" + p.getLastSavedDate());
}

for (ProjectInfo p : (Iterable)reader.getProjectList())
{
    Project project = reader.getProject(p.getId());
    System.out.println("Project " + p.getName() + " loaded.");
    System.out.println("Resources count:" + project.getResources().size());
}

Java アプリでのタスク処理とスケジューリング

Aspose.Tasks for Java supports create mew tasks, task scheduling and allows software developers to manage task dependencies effectively. It enables developers to modify project data effortlessly. You can update tasks, resources, and other details programmatically. There are several important features part of the library that allows users to handle project tasks, such as adding new tasks, getting and setting tasks properties, associating calendars with particular tasks, manage task duration in projects, managing critical and effort-driven tasks, and many more. The following examples increases and decreases the task duration to 1 week and half week respectively.

Java アプリケーション内でプロジェクトのタスク期間を管理する方法

// Create a new project and add a new task
Project project = new Project();
Task task = project.getRootTask().getChildren().add("Task");

// Task duration in days (default time unit)
Duration duration = task.get(Tsk.DURATION);
System.out.println("Duration equals 1 day:" + duration.toString().equals("1 day"));

// Convert to hours time unit
duration = duration.convert(TimeUnitType.Hour);
System.out.println("Duration equals 8 hrs: "+ duration.toString().equals("8 hrs"));

// Increase task duration to 1 week and display if duration is updated successfully
task.set(Tsk.DURATION, project.getDuration(1, TimeUnitType.Week));
System.out.println("Duration equals 1 wk: " + task.get(Tsk.DURATION).toString().equals("1 wk"));

// Decrease task duration and display if duration is updated successfully
task.set(Tsk.DURATION, task.get(Tsk.DURATION).subtract(0.5));
System.out.println("Duration equals 0.5 wks: " + task.get(Tsk.DURATION).toString().equals("0.5 wks"));

Java API を使用したプロジェクト データの PDF 変換

Aspose.Tasks for Java makes it easy for software developers to load and save project data to various important file formats inside Java applications. The Project class exposes the Save method which can be used to save a project in various formats. The Save method allows users to load and render project data to PDF file format with just a couple of lines of Java code. The following example demonstrates how to Render project data to PDF using Java commands.

Java アプリケーション内でプロジェクト データを PDF にエクスポートする方法


// The path to the documents directory.
String dataDir = Utils.getDataDir(SaveAsPdf.class);

// Read the input Project file
Project project = new Project(dataDir + "project6.mpp");

project.save(dataDir + "Project5.pdf", SaveFileFormat.PDF);

// Fitting contents to cell size
Project project1 = new Project(dataDir + "project6.mpp");
SaveOptions o = new PdfSaveOptions();

// Set the LegendOnEachPage property to false to hide legends

// Set the row height to fit cell content
o.setFitContent(true);
o.setTimescale(Timescale.Months);
o.setPresentationFormat(PresentationFormat.TaskUsage);
project1.save("result_months.pdf", o);
o.setLegendOnEachPage(false);
project1.save(dataDir + "result_months_WithoutLegend.pdf", o);

// Display result of conversion.
System.out.println("Process completed Successfully");

 日本