Convertir los datos del proyecto para sobresalir en c ++

Este artículo demuestra cómo guardar los datos del proyecto en formato XLSX usando Aspose.Tasks para C ++.

La clase Proyecto expone el método Guardar que se utiliza para guardar un proyecto en varios formatos. El método Guardar le permite guardar tareas, recursos y tareas del proyecto para separar las hojas de trabajo en formato XLSX utilizando el tipo de enumeración SaveFileFormat.

Para guardar un proyecto en XLSX:

  1. Cargue un archivo de proyecto de Microsoft.
  2. Guarde el proyecto en XLSX usando SaveFileFormat.xlsx.

Guardar un proyecto como xlsx

Las siguientes líneas de código demuestran cómo lograr esto usando C ++.

1// Read the input Project file
2System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
3    
4// Save the Project as XLSX
5project->Save(dataDir + u"SaveProjectAsXLSX_out.xlsx", Aspose::Tasks::Saving::SaveFileFormat::XLSX);

Using XlsxOptions

With XlsxOptions, you can modify how the project is exported.

 1// Read the input Project file
 2System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
 3    
 4System::SharedPtr<XlsxOptions> options = System::MakeObject<XlsxOptions>();
 5    
 6// Add desired Gantt Chart columns
 7System::SharedPtr<GanttChartColumn> col = System::MakeObject<GanttChartColumn>(u"WBS", 100, &UsingXlsxOptions::_anonymous_method_0);
 8options->get_View()->get_Columns()->Add(col);
 9    
10// Add desired resource view columns
11System::SharedPtr<ResourceViewColumn> rscCol = System::MakeObject<ResourceViewColumn>(u"Cost center", 100, &UsingXlsxOptions::_anonymous_method_1);
12options->get_ResourceView()->get_Columns()->Add(rscCol);
13    
14// Add desired assignment view columns
15System::SharedPtr<AssignmentViewColumn> assnCol = System::MakeObject<AssignmentViewColumn>(u"Notes", 200, &UsingXlsxOptions::_anonymous_method_2);
16options->get_AssignmentView()->get_Columns()->Add(assnCol);
17    
18project->Save(dataDir + u"UsingXlsxOptions_out.xlsx", options);

Save Project Data to Spreadsheet2003 XML

There are two ways to save data to Spreadsheet2003 XML format: default, or using save options. Using the SaveFileFormat instance, the default view data is saved.

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
2project->Save(dataDir + u"SaveProjectDataToSpreadsheet2003XML_out.xml", Aspose::Tasks::Saving::SaveFileFormat::Spreadsheet2003);

Using Spreadsheet2003SaveOptions

Aspose.Tasks for C++ provides Spreadsheet2003SaveOptions for modifying the view data.

 1System::SharedPtr<Spreadsheet2003SaveOptions> options = System::MakeObject<Spreadsheet2003SaveOptions>();
 2System::SharedPtr<GanttChartColumn> col = System::MakeObject<GanttChartColumn>(u"WBS", 100, &UsingSpreadsheet2003SaveOptions::_anonymous_method_0);
 3options->get_View()->get_Columns()->Add(col);
 4    
 5System::SharedPtr<ResourceViewColumn> rscCol = System::MakeObject<ResourceViewColumn>(u"Cost center", 100, &UsingSpreadsheet2003SaveOptions::_anonymous_method_1);
 6options->get_ResourceView()->get_Columns()->Add(rscCol);
 7    
 8System::SharedPtr<AssignmentViewColumn> assnCol = System::MakeObject<AssignmentViewColumn>(u"Notes", 200, &UsingSpreadsheet2003SaveOptions::_anonymous_method_2);
 9options->get_AssignmentView()->get_Columns()->Add(assnCol);
10    
11project->Save(dataDir + u"UsingSpreadsheet2003SaveOptions_out.xml", options);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.