C ++에서 프로젝트 데이터를 Excel로 변환하십시오

이 기사는 C ++ 용 Aspose.Tasks 를 사용하여 프로젝트 데이터를 XLSX 형식으로 저장하는 방법을 보여줍니다.

Project 클래스는 프로젝트를 다양한 형식으로 저장하는 데 사용되는 저장 메소드를 노출시킵니다. 저장 메소드를 사용하면 SaveFileFormat 열거 유형을 사용하여 프로젝트 작업, 리소스 및 과제를 XLSX 형식으로 별도의 워크 시트로 저장할 수 있습니다.

프로젝트를 XLSX에 저장하려면 :

  1. Microsoft 프로젝트 파일을로드하십시오.
  2. savefileformat.xlsx를 사용하여 프로젝트를 xlsx에 저장하십시오.

프로젝트 저장 XLSX

다음 줄의 코드는 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.