PNG JPG BMP TIFF PPT
Aspose.Slides  for Java

Biểu đồ định dạng PPT trong Java

Biểu đồ tài liệu PPT nguyên bản và hiệu suất cao bằng cách sử dụng Aspose.Slides phía máy chủ cho các API Java mà không cần sử dụng bất kỳ phần mềm nào như Microsoft hoặc Adobe PDF.

Cách tạo biểu đồ tệp PPT bằng Java

Để tạo biểu đồ tệp PPT, chúng tôi sẽ sử dụng

Aspose.Slides dành cho Java

API là một API biểu đồ giàu tính năng, mạnh mẽ và dễ sử dụng cho nền tảng Java. Bạn có thể tải xuống phiên bản mới nhất của nó trực tiếp từ

Maven

và cài đặt nó trong dự án dựa trên Maven của bạn bằng cách thêm các cấu hình sau vào pom.xml.

Kho


<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository>

Sự phụ thuộc


<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>version of aspose-slides API</version>
    <classifier>jdk17</classifier>
</dependency>

Các bước tạo biểu đồ tệp PPT trong Java

Lập biểu đồ tài liệu cơ bản với API Aspose.Slides for Java có thể được thực hiện chỉ với vài dòng mã.

  1. Khởi tạo đối tượng lớp Trình bày.

  2. Nhận trang trình bày đầu tiên.

  3. Thêm biểu đồ với dữ liệu mặc định.

  4. Đặt tiêu đề biểu đồ.

  5. Đặt sê-ri đầu tiên thành Hiển thị giá trị.

  6. Đặt chỉ số của bảng dữ liệu biểu đồ.

  7. Nhận bảng dữ liệu biểu đồ.

  8. Xóa chuỗi và danh mục được tạo mặc định.

  9. Thêm chuỗi và danh mục mới.

  10. Lấy chuỗi biểu đồ đầu tiên.

  11. Điền dữ liệu chuỗi.

  12. Đặt màu tô cho chuỗi.

  13. tạo nhãn tùy chỉnh cho từng danh mục cho loạt phim mới.

  14. Lưu bản trình bày với biểu đồ.

yêu cầu hệ thống

Aspose.Slides cho Java hỗ trợ trên tất cả các nền tảng và Hệ điều hành chính. Vui lòng đảm bảo rằng bạn có các điều kiện tiên quyết sau.

  • Microsoft Windows hoặc hệ điều hành tương thích với Môi trường thời gian chạy Java cho Ứng dụng JSP / JSF và Ứng dụng máy tính để bàn.
  • Nhận phiên bản mới nhất của Aspose.Slides cho Java trực tiếp từ Maven .
 

Tạo biểu đồ tệp PPT - Java

//Instantiate Presentation class 
Presentation pres = new Presentation();

//Access first slide
ISlide sld = pres.getSlides().get_Item(0);

// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);

//Setting chart Title
//chart.getChartTitle().TextFrameForOverriding.Text = "Title";
chart.getChartTitle().addTextFrameForOverriding("Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle(true);

//Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);

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

//Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();

//Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();

//Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());

//Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));

//Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);

//Now populating series data

series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));

//Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.RED);

//Take second chart series
series = chart.getChartData().getSeries().get_Item(1);

//Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));

//Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.GREEN);

//create custom labels for each of categories for new series

//first label will be show Category name
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowCategoryName(true);

lbl = series.getDataPoints().get_Item(1).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(true);

//Show value for third label
lbl = series.getDataPoints().get_Item(2).getLabel();
lbl.getDataLabelFormat().setShowValue(true);
lbl.getDataLabelFormat().setShowSeriesName(true);
lbl.getDataLabelFormat().setSeparator("/");

//Save presentation with chart
pres.save("AsposeChart.ppt",SaveFormat.Ppt);  

    
 
  • Giới thiệu về Aspose.Slides cho Java API

    Tạo biểu đồ tài liệu PPT ngay bây giờ bằng cách truy cập

    Trang web trình diễn trực tiếp

    . Bản demo trực tiếp có những lợi ích sau

    Online PPT Chart Creation Live Demos

    Generate PPT 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 PPT files.
      Chart will be created instantly.

    PPT Những gì là PPT Tập Tin Định Dạng

    A file with PPT extension represents PowerPoint file that consists of a collection of slides for displaying as SlideShow. It specifies the Binary File Format used by Microsoft PowerPoint 97-2003. A PPT file can contain several different types of information such as text, bulleted points, images, multimedia and other embedded OLE objects. Microsoft came up with newer file format for PowerPoint, known as PPTX, from 2007 onwards that is based on Office OpenXML and is different from this binary file format. Several other application programs such as OpenOffice Impress and Apple Keynote can also create PPT files.

    Đọc Thêm

    Các định dạng biểu đồ được hỗ trợ khác

    Sử dụng Java, người ta có thể dễ dàng xử lý chuỗi với các định dạng khác nhau bao gồm.

    PPTX (Định dạng bản trình bày XML mở)