public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(HidingTheShapesFromSlide.class);
    Presentation presentation1 = new Presentation();
    ISlide slide = presentation1.getSlides().get_Item(0);
    for (int i = 0; i < slide.getShapes().size(); i++) {
      IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(i);
      ashp.setHidden(true);
    }
    presentation1.save(dataDir + "sample_output.pptx", SaveFormat.Pptx);
  }
  public static final void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(CreateAPresentation.class);

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

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

    // Add an AutoShape of Rectangle type
    IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);

    // Add ITextFrame to the Rectangle
    ashp.addTextFrame("Hello World");

    // Change the text color to Black (which is White by default)
    ashp.getTextFrame()
        .getParagraphs()
        .get_Item(0)
        .getPortions()
        .get_Item(0)
        .getPortionFormat()
        .getFillFormat()
        .setFillType(FillType.Solid);
    ashp.getTextFrame()
        .getParagraphs()
        .get_Item(0)
        .getPortions()
        .get_Item(0)
        .getPortionFormat()
        .getFillFormat()
        .getSolidFillColor()
        .setColor(java.awt.Color.BLACK);

    // Change the line color of the rectangle to White
    ashp.getShapeStyle().getLineColor().setColor(java.awt.Color.WHITE);

    // Remove any fill formatting in the shape
    ashp.getFillFormat().setFillType(FillType.NoFill);

    // Save the presentation to disk
    pres.save(dataDir + "HelloWorld.pptx", com.aspose.slides.SaveFormat.Pptx);
  }
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(UpdatingExistingChart.class);

    // Instantiate Presentation class that represents PPTX file
    Presentation pres = new Presentation(dataDir + "ExistingChart.pptx");

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

    // Add chart with default data
    IChart chart = (IChart) sld.getShapes().get_Item(0);

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

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

    // Changing chart Category Name
    fact.getCell(defaultWorksheetIndex, 1, 0, "Modified Category 1");
    fact.getCell(defaultWorksheetIndex, 2, 0, "Modified Category 2");

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

    // Now updating series data
    fact.getCell(defaultWorksheetIndex, 0, 1, "New_Series1");

    // modifying series name
    series.getDataPoints().get_Item(0).getValue().setData(90);
    series.getDataPoints().get_Item(1).getValue().setData(123);
    series.getDataPoints().get_Item(2).getValue().setData(44);

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

    // Now updating series data
    fact.getCell(defaultWorksheetIndex, 0, 2, "New_Series2");

    // modifying series name
    series.getDataPoints().get_Item(0).getValue().setData(23);
    series.getDataPoints().get_Item(1).getValue().setData(67);
    series.getDataPoints().get_Item(2).getValue().setData(99);

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

    // Take 3rd chart series
    series = chart.getChartData().getSeries().get_Item(2);

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

    chart.setType(ChartType.ClusteredCylinder);

    // Save presentation with chart
    pres.save(dataDir + "AsposeChartModified.pptx", SaveFormat.Pptx);
  }
Ejemplo n.º 4
0
  public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(ScatteredChart.class);
    Presentation pres = new Presentation();

    ISlide slide = pres.getSlides().get_Item(0);

    // Creating the default chart
    IChart chart = slide.getShapes().addChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);

    // Getting the default chart data worksheet index
    int defaultWorksheetIndex = 0;

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

    // Delete demo series
    chart.getChartData().getSeries().clear();

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

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

    // Add new point (1:3) there.
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 2, 1, 1),
            fact.getCell(defaultWorksheetIndex, 2, 2, 3));

    // Add new point (2:10)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 3, 1, 2),
            fact.getCell(defaultWorksheetIndex, 3, 2, 10));

    // Edit the type of series
    series.setType(ChartType.ScatterWithStraightLinesAndMarkers);

    // Changing the chart series marker
    series.getMarker().setSize(10);
    series.getMarker().setSymbol(MarkerStyleType.Star);

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

    // Add new point (5:2) there.
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 2, 3, 5),
            fact.getCell(defaultWorksheetIndex, 2, 4, 2));

    // Add new point (3:1)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 3, 3, 3),
            fact.getCell(defaultWorksheetIndex, 3, 4, 1));

    // Add new point (2:2)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 4, 3, 2),
            fact.getCell(defaultWorksheetIndex, 4, 4, 2));

    // Add new point (5:1)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 5, 3, 5),
            fact.getCell(defaultWorksheetIndex, 5, 4, 1));

    // Changing the chart series marker
    series.getMarker().setSize(10);
    series.getMarker().setSymbol(MarkerStyleType.Circle);

    pres.save(dataDir + "AsposeScatterChart.pptx", SaveFormat.Pptx);
  }