PNG JPG BMP TIFF PPTX
Aspose.Slides  for C++

C++에서 PPTX 형식 차트

Microsoft 또는 Adobe PDF와 같은 소프트웨어를 사용하지 않고 C++ API용 서버측 Aspose.Slides를 사용하는 기본 및 고성능 PPTX 문서 차트.

C++를 사용하여 PPTX 파일 차트를 만드는 방법

PPTX 파일을 검색하려면 다음을 사용합니다.

C++용 Aspose.Slides

기능이 풍부하고 강력하며 사용하기 쉬운 C++ 플랫폼용 문서 검색 API인 API입니다. 최신 버전을 직접 다운로드할 수 있습니다.

NuGet

패키지 관리자, 검색 Aspose.Slides.Cpp 설치합니다. 패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

명령


PM> Install-Package Aspose.Slides.Cpp

C++에서 PPTX 파일 차트를 만드는 단계

Aspose.Slides for C++ API를 사용한 기본 문서 차트 작성은 몇 줄의 코드로 수행할 수 있습니다.

  1. Presentation 클래스를 인스턴스화합니다.

  2. 첫 번째 슬라이드에 액세스합니다.

  3. 기본 데이터가 있는 차트 추가

  4. 차트 데이터 시트의 인덱스를 설정합니다.

  5. 차트 데이터 통합 ​​문서를 가져옵니다.

  6. 차트 제목을 설정합니다.

  7. 기본 생성 시리즈 및 카테고리를 삭제합니다.

  8. 시리즈 및 카테고리를 추가합니다.

  9. 첫 번째 차트 시리즈를 가져와 데이터를 채웁니다.

  10. 시리즈의 채우기 색상을 설정합니다.

  11. PPTX 파일을 저장합니다.

시스템 요구 사항

C++용 Aspose.Slides는 모든 주요 플랫폼 및 운영 체제를 지원합니다. 다음 전제 조건이 있는지 확인하십시오.

  • Microsoft Windows 또는 Windows 32비트, Windows 64비트 및 Linux 64비트용 C++ 런타임 환경과 호환되는 OS.
  • 프로젝트에서 참조되는 C++ DLL용 Aspose.Slides.
 

PPTX 파일 차트 만들기 - C++

// Output File Path.
const String outputFilePath = u"OutputDirectory\\column_chart.pptx";

// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>();

// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);

// Add chart with default data
SharedPtrv<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);

// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

// Getting the chart data workbook
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();

// Setting chart Title
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title");
chart->get_ChartTitle()->get_TextFrameForOverriding()->get_TextFrameFormat()->set_CenterText(NullableBool::True);
chart->get_ChartTitle()->set_Height(20);
chart->set_HasTitle(true);

// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
int s = chart->get_ChartData()->get_Series()->get_Count();
s = chart->get_ChartData()->get_Categories()->get_Count();

// Add series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());

// Add categories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"Category 2")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"Category 3")));

// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);

// Populate series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box(30)));

// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());

// Take second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);

// Populate series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box(60)));

// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Orange());

// First label will be show Category name
SharedPtr<IDataLabel> lbl = series->get_DataPoints()->idx_get(0)->get_Label();
lbl->get_DataLabelFormat()->set_ShowCategoryName(true);

lbl = series->get_DataPoints()->idx_get(1)->get_Label();
lbl->get_DataLabelFormat()->set_ShowSeriesName(true);

// Show value for third label
lbl = series->get_DataPoints()->idx_get(2)->get_Label();
lbl->get_DataLabelFormat()->set_ShowValue(true);
lbl->get_DataLabelFormat()->set_ShowSeriesName(true);
lbl->get_DataLabelFormat()->set_Separator(u"/");

// Save PPTX file
pres->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);  

    
 
  • C++ API용 Aspose.Slides 정보

    우리를 방문하여 지금 PPTX 문서 차트를 생성

    라이브 데모 홈페이지

    . 라이브 데모에는 다음과 같은 이점이 있습니다.

    Online PPTX Chart Creation Live Demos

    Generate PPTX documents charts right now by visiting our Live Demos website . The live demo has the following benefits

      No need to download Aspose API.
      No need to write any code.
      Just upload your PPTX files.
      Chart will be created instantly.

    PPTX PPTX 파일 형식이란 무엇입니까?

    Files with PPTX extension are presentation files created with popular Microsoft PowerPoint application. Unlike the previous version of presentation file format PPT which was binary, the PPTX format is based on the Microsoft PowerPoint open XML presentation file format. A presentation file is a collection of slides where each slide can comprise of text, images, formatting, animations, and other media. These slides are presented to audience in the form of slideshows with custom presentation settings.

    더 읽기

    기타 지원되는 차트 형식

    C++를 사용하면 다음을 포함한 다양한 형식으로 충전을 쉽게 처리할 수 있습니다.

    PPT (마이크로소프트 파워포인트 97-2003)