Convert Project Data to CSV, Text and MPT
Contents
[
Hide
Show
]Microsoft Project (MSP) allows developers to save project data (MPP/XML) comma-delimited (CSV), text and MPT templates. Aspose.Tasks for C++ API also allows you to save project data to the same formats similar to MSP. This is achieved using the standard Save method exposed by the Project class.
Saving a Project as CSV
The following code snippet shows how to save a project as a CSV format.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject1.mpp");
2project->Save(dataDir + u"SaveProjectAsCSV_out.csv", Aspose::Tasks::Saving::SaveFileFormat::CSV);
Save Project to Text
1// Read the input Project file
2System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
3
4// Save the Project as text
5project->Save(dataDir + u"SaveProjectAsText_out.txt", Aspose::Tasks::Saving::SaveFileFormat::TXT);
Save Project Data as Template (MPT)
1const System::String projectName = u"Project2.mpp";
2System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + projectName);
3System::SharedPtr<ProjectFileInfo> projectFileInfo = Project::GetProjectFileInfo(dataDir + projectName);
4
5if (Aspose::Tasks::FileFormat::MPP14 == projectFileInfo->get_ProjectFileFormat())
6{
7 System::Console::WriteLine(u"Project file format is ok");
8}
9
10System::SharedPtr<SaveTemplateOptions> options = System::MakeObject<SaveTemplateOptions>();
11options->set_RemoveActualValues(true);
12options->set_RemoveBaselineValues(true);
13
14const System::String templateName = u"SaveProjectDataAsTemplate_out.mpt";
15project->SaveAsTemplate(dataDir + templateName);
16
17System::SharedPtr<ProjectFileInfo> templateFileInfo = Project::GetProjectFileInfo(dataDir + templateName);
18if (Aspose::Tasks::FileFormat::MPT14 == templateFileInfo->get_ProjectFileFormat())
19{
20 System::Console::WriteLine(u"Template FileFormat is ok");
21}