
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.
¿Qué es Aspose.Tasks para 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.
Comenzando con Aspose.Tasks para Java
La forma recomendada de instalar Aspose.Tasks para Java es a través del repositorio Maven. Puedes usar fácilmente la API Aspose.Words para Java directamente en tus proyectos Maven con configuraciones simples.
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 Página de lanzamientoCrear un nuevo archivo de proyecto con 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.
¿Cómo generar un proyecto vacío dentro de aplicaciones 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
}
}
Lectura de archivos de proyecto mediante la API Java
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.
¿Cómo leer un archivo de proyecto en línea usando la API Java?
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());
}
Manejo y programación de tareas en aplicaciones 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.
¿Cómo gestionar la duración de las tareas del proyecto dentro de aplicaciones 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"));
Conversión de datos del proyecto a PDF mediante la API Java
Aspose.Tasks para Java facilita a los desarrolladores de software cargar y guardar datos del proyecto en varios formatos de archivo importantes dentro de aplicaciones Java. 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.
¿Cómo exportar datos del proyecto a PDF dentro de aplicaciones Java?
// 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");
