1. Products
  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.

In the fast-paced world of project management, having the right tools at your disposal can make all the difference.Aspose.Tasks for Java emerges as a powerful solution, offering a comprehensive set of features to streamline project-related tasks and enhance overall efficiency. The library provides a user-friendly and intuitive API that makes it easy for software developers to integrate project management functionalities into their Java applications. With a few lines of code, java developers can read project data, update task information, and generate reports effortlessly.

Aspose.Tasks for Java is a robust Java library designed to work seamlessly with Microsoft Project files, allowing software developers to manipulate and manage project data effortlessly. Whether you are creating, reading, updating, or converting project files, this library simplifies the process, making it an invaluable asset for Java developers in the project management domain. The library provides support for a wide range of Microsoft Project file formats, including MPP, XML, and MPX. This flexibility ensures compatibility with various versions of Microsoft Project, giving developers the freedom to work with different file types without any compatibility issues.

Aspose.Tasks for Java excels in its ability to handle complex project structures and intricate details. Developers can manipulate tasks, resources, and dependencies with precision, ensuring that the project data remains accurate and up-to-date. This level of control is crucial for applications that demand a high degree of accuracy in project planning and execution. The library also comes equipped with advanced features such as task scheduling, resource allocation, and Gantt chart generation. These features enable developers to create dynamic and interactive project management solutions that cater to the specific needs of their users. In conclusion, Aspose.Tasks emerges as a game-changer for Java developers involved in project management applications. Its rich feature set, compatibility with various file formats, and intuitive API make it a reliable choice for those seeking to enhance project management efficiency.

Previous Next

Getting Started with 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 Dependency

 //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>
You can download the directly from Aspose.Tasks Release page

Create a New Project File via 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.

How to Generate an Empty Project inside Java Applications?

 
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
    }
}

Reading Project Files via 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.

How to Read Project File Online Using 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());
}

Task Handling & Scheduling in Java Apps

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.

How to Manage Project’s Task Duration inside java Applications?

// 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"));

Project Data Conversion to PDF via Java API

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.

How to Export Project Data to PDF inside Java Applications?


// 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");