Package com.aspose.slides

Examples of com.aspose.slides.Presentation


public class AsposeSettingPieChartSectorColors
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents PPTX file
    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.Pie, 100, 100, 400, 400);

    //Setting chart Title
    chart.getChartTitle().addTextFrameForOverriding("Sample 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();

    //Adding new categories
    chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "First Qtr"));
    chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "2nd Qtr"));
    chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "3rd Qtr"));

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

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


    //Not working in new version
    //Adding new points and setting sector color
    //series.IsColorVaried = true;
    chart.getChartData().getSeriesGroups().get_Item(0).isColorVaried(true);

    IChartDataPoint point = series.getDataPoints().get_Item(0);
    point.getFormat().getFill().setFillType(FillType.Solid);
    point.getFormat().getFill().getSolidFillColor().setColor(Color.CYAN);
    //Setting Sector border
    point.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    point.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
    point.getFormat().getLine().setWidth(3.0);
    point.getFormat().getLine().setStyle(LineStyle.ThinThick);
    point.getFormat().getLine().setDashStyle(LineDashStyle.DashDot);


    IChartDataPoint point1 = series.getDataPoints().get_Item(1);
    point1.getFormat().getFill().setFillType (FillType.Solid);
    point1.getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.Brown));

    //Setting Sector border
    point1.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    point1.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
    point1.getFormat().getLine().setWidth(3.0);
    point1.getFormat().getLine().setStyle(LineStyle.Single);
    point1.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDot);

    IChartDataPoint point2 = series.getDataPoints().get_Item(2);
    point2.getFormat().getFill().setFillType(FillType.Solid);
    point2.getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.Coral));

    //Setting Sector border
    point2.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    point2.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
    point2.getFormat().getLine().setWidth(2.0);
    point2.getFormat().getLine().setStyle(LineStyle.ThinThin);
    point2.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDotDot);


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

    IDataLabel lbl1 = series.getDataPoints().get_Item(0).getLabel();
    // lbl.ShowCategoryName = true;
    lbl1.getDataLabelFormat().setShowValue(true);


    IDataLabel lbl2 = series.getDataPoints().get_Item(1).getLabel();
    lbl2.getDataLabelFormat().setShowValue (true);
    lbl2.getDataLabelFormat().setShowLegendKey(true);
    lbl2.getDataLabelFormat().setShowPercentage(true);

    IDataLabel lbl3 = series.getDataPoints().get_Item(2).getLabel();
    lbl3.getDataLabelFormat().setShowSeriesName(true);
    lbl3.getDataLabelFormat().setShowPercentage (true);


    //Showing Leader Lines for Chart
    series.getLabels().getDefaultDataLabelFormat().setShowLeaderLines(true);

    //Setting Rotation Angle for Pie Chart Sectors
    chart.getChartData().getSeriesGroups().get_Item(0).setFirstSliceAngle(180);

    // Save presentation with chart
    pres.save("data/AsposePieChart.pptx", SaveFormat.Pptx);
   
    System.out.println("Done");
  }
View Full Code Here


public class AsposeCountSlides
{
  public static void main(String[] args)
  {
    //Instantiate a PresentationEx object that represents a PPTX file
    Presentation pres = new Presentation("data/presentation.pptx");

    System.out.println("Total Slides in Count: " + pres.getSlides().size());
  }
View Full Code Here

public class AsposeConvertToImage
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a PresentationEx object that represents a PPTX file
    Presentation pres = new Presentation("data/presentation.pptx");
   
    //Instantiate the TiffOptions class
    TiffOptions opts = new TiffOptions();
   
    //Set Image Size
    opts.setImageSize(new Dimension(500, 400));
   
    //Save the prsentation to TIFF with specified image size
    pres.save("data/Aspose_PPT-TIFF.tiff", SaveFormat.Tiff, opts);

    System.out.println("Slide Converted to Image Successfully");
  }
View Full Code Here

public class AsposeFormatting
{
  public static void main(String[] args)
  {
    //Instantiate a Presentation object that represents a PPTX file
      Presentation pres = new Presentation("data/unformatted.pptx");

      //Accessing a slide using its slide position
      ISlide slide = pres.getSlides().get_Item(0);

      //Accessing the first and second placeholder in the slide and typecasting it as AutoShape
      ITextFrame tf1 = ((IAutoShape)slide.getShapes().get_Item(0)).getTextFrame();
      ITextFrame tf2 = ((IAutoShape)slide.getShapes().get_Item(1)).getTextFrame();

      //Accessing the first Paragraph
      IParagraph para1 = tf1.getParagraphs().get_Item(0);
      IParagraph para2 = tf2.getParagraphs().get_Item(0);

      //Accessing the first portion
      IPortion port1 = para1.getPortions().get_Item(0);
      IPortion port2 = para2.getPortions().get_Item(0);

      //Define new fonts
      FontData fd1 = new FontData("Elephant");
      FontData fd2 = new FontData("Castellar");

      //Assign new fonts to portion
      port1.getPortionFormat().setLatinFont(fd1);
      port2.getPortionFormat().setLatinFont(fd2);

      //Set font to Bold
      port1.getPortionFormat().setFontBold(NullableBool.True);
      port2.getPortionFormat().setFontBold(NullableBool.True);

      //Set font to Italic
      port1.getPortionFormat().setFontItalic(NullableBool.True);
      port2.getPortionFormat().setFontItalic(NullableBool.True);

      //Set font color
      port1.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
      port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
      port2.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
      port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN);

      //Save the PPTX to disk
      pres.save("data/FontFormatting_Aspose.pptx", SaveFormat.Pptx);
     
      System.out.println("Formatted Presentation Saved.");
  }
View Full Code Here

public class AsposeAddImagesInSlides
{
  public static void main(String[] args)
  {
    //Instantiate a Presentation object that represents a PPT file
    Presentation pres = new Presentation("data/presentation.ppt");
   
    //Accessing a slide using its slide position
    ISlide slide = pres.getSlides().get_Item(0);
   
    //===========================================================
    // Plain Line
    //===========================================================
    //Adding a line shape into the slide with its start and end points
    slide.getShapes().addAutoShape(ShapeType.Line, 50, 50, 400, 0);

    //===========================================================
    // Adding Simple Ellipse in the Slide
    //============================================================
    //Adding an ellipse shape into the slide by defining its X,Y postion, width and height
    slide.getShapes().addAutoShape(ShapeType.Ellipse, 270, 150, 350, 50);
      
    //============================================================
    // Adding Simple Rectangle in the Slide
    //============================================================
   
    //Adding a rectangle shape into the slide by defining its X,Y position, width and height
    slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 200, 100);
   
    //===========================================================
    // Arrow Shaped Line
    //============================================================
    ///Add an autoshape of type line

        IAutoShape shp = slide.getShapes().addAutoShape(ShapeType.Line, 50, 130, 300, 0);

        //Apply some formatting on the line
        shp.getLineFormat().setStyle (LineStyle.ThickBetweenThin);
        shp.getLineFormat().setWidth ( 10);

        shp.getLineFormat().setDashStyle  (LineDashStyle.DashDot);

        shp.getLineFormat().setBeginArrowheadLength(LineArrowheadLength.Short);
        shp.getLineFormat().setBeginArrowheadStyle (LineArrowheadStyle.Oval);

        shp.getLineFormat().setEndArrowheadLength (LineArrowheadLength.Long);
        shp.getLineFormat().setEndArrowheadStyle (LineArrowheadStyle.Triangle);

        shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
        shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(new Color(com.aspose.slides.PresetColor.Maroon));
      
    //===========================================================
    // Adding Formatted Ellipse in the Slide
    //============================================================
        //Add autoshape of ellipse type
        shp = slide.getShapes().addAutoShape(ShapeType.Ellipse, 270, 350, 350, 50);

        //Apply some formatting to ellipse shape
        shp.getFillFormat().setFillType(FillType.Solid);
        shp.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.Chocolate));

        //Apply some formatting to the line of Ellipse
        shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
        shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
        shp.getLineFormat().setWidth(5);
   
    //============================================================
    // Adding Formatted Rectangle to Slide
    //============================================================
    //Adding a rectangle shape into the slide by defining its X,Y position, width and height
        shp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 350, 200, 100);

        //Apply some formatting to ellipse shape
        shp.getFillFormat().setFillType(FillType.Solid);
        shp.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.Chocolate));

        //Apply some formatting to the line of Ellipse
        shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
        shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
        shp.getLineFormat().setWidth(5);
   
    //Writing the presentation as a PPT file
    pres.save("data/ImageInSlides_Aspose.pptx", SaveFormat.Pptx);
       
        //Print Message
        System.out.println("Shapes added successfully.");
  }
View Full Code Here

public class AsposeFormattingChartEntities
{
  public static void main(String[] args)
  {
    //Instantiating presentation//Instantiating presentation
    Presentation pres = new Presentation();

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

    //Adding the sample chart
    IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 50, 50, 500, 400);

    //Setting Chart Titile
    chart.hasTitle(true);
    chart.getChartTitle().addTextFrameForOverriding("");
    IPortion chartTitle = chart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
    chartTitle.setText("Sample Chart");
    chartTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
    chartTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
    chartTitle.getPortionFormat().setFontHeight (20);
    chartTitle.getPortionFormat().setFontBold(NullableBool.True);
    chartTitle.getPortionFormat().setFontItalic(NullableBool.True);

    //Setting Major grid lines format for value axis
    chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
    chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setWidth(5);
    chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setDashStyle(LineDashStyle.DashDot);

    //Setting Minor grid lines format for value axis
    chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
    chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().setWidth(3);

    //Setting value axis number format
    chart.getAxes().getVerticalAxis().isNumberFormatLinkedToSource(false);
    chart.getAxes().getVerticalAxis().setDisplayUnit(DisplayUnitType.Thousands);
    chart.getAxes().getVerticalAxis().setNumberFormat("0.0%");

    //Setting chart maximum, minimum values
    chart.getAxes().getVerticalAxis().isAutomaticMajorUnit(false);
    chart.getAxes().getVerticalAxis().isAutomaticMaxValue(false);
    chart.getAxes().getVerticalAxis().isAutomaticMinorUnit(false);
    chart.getAxes().getVerticalAxis().isAutomaticMinValue(false);

    chart.getAxes().getVerticalAxis().setMaxValue(15f);
    chart.getAxes().getVerticalAxis().setMinValue(-2f);
    chart.getAxes().getVerticalAxis().setMinorUnit(0.5f);
    chart.getAxes().getVerticalAxis().setMajorUnit(2.0f);

    //Setting Value Axis Text Properties
    IChartPortionFormat txtVal = chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat();
    txtVal.setFontBold(NullableBool.True);
    txtVal.setFontHeight(16);
    txtVal.setFontItalic(NullableBool.True);
    txtVal.getFillFormat().setFillType(FillType.Solid);
    txtVal.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DarkGreen));
    txtVal.setLatinFont(new FontData("Times New Roman"));

    //Setting value axis title
    chart.getAxes().getVerticalAxis().hasTitle(true);
    chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("");
    IPortion valtitle = chart.getAxes().getVerticalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
    valtitle.setText("Primary Axis");
    valtitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
    valtitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
    valtitle.getPortionFormat().setFontHeight(20);
    valtitle.getPortionFormat().setFontBold(NullableBool.True);
    valtitle.getPortionFormat().setFontItalic(NullableBool.True);

    //Setting Major grid lines format for Category axis
    chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
    chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().setWidth(5);

    //Setting Minor grid lines format for Category axis
    chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.YELLOW);
    chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().setWidth(3);

    //Setting Category Axis Text Properties
    IChartPortionFormat txtCat = chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat();
    txtCat.setFontBold(NullableBool.True);
    txtCat.setFontHeight(16);
    txtCat.setFontItalic(NullableBool.True);
    txtCat.getFillFormat().setFillType(FillType.Solid) ;
    txtCat.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
    txtCat.setLatinFont(new FontData("Arial"));

    //Setting Category Titile
    chart.getAxes().getHorizontalAxis().hasTitle(true);
    chart.getAxes().getHorizontalAxis().getTitle().addTextFrameForOverriding("");

    IPortion catTitle = chart.getAxes().getHorizontalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0);
    catTitle.setText("Sample Category");
    catTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
    catTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
    catTitle.getPortionFormat().setFontHeight(20);
    catTitle.getPortionFormat().setFontBold(NullableBool.True);
    catTitle.getPortionFormat().setFontItalic(NullableBool.True);

    //Setting category axis lable position
    chart.getAxes().getHorizontalAxis().setTickLabelPosition(TickLabelPositionType.Low);

    //Setting category axis lable rotation angle
    chart.getAxes().getHorizontalAxis().setTickLabelRotationAngle(45);

    //Setting Legends Text Properties
    IChartPortionFormat txtleg = chart.getLegend().getTextFormat().getPortionFormat();
    txtleg.setFontBold(NullableBool.True);
    txtleg.setFontHeight(16);
    txtleg.setFontItalic(NullableBool.True);
    txtleg.getFillFormat().setFillType(FillType.Solid);
    txtleg.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DarkRed));

    //Set show chart legends without overlapping chart

    chart.getLegend().setOverlay(true);
    //chart.ChartData.Series[0].PlotOnSecondAxis=true;

    chart.getChartData().getSeries().get_Item(0).setPlotOnSecondAxis(true);
    //Setting secondary value axis
    chart.getAxes().getSecondaryVerticalAxis().isVisible(true);
     chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setStyle(LineStyle.ThickBetweenThin);
     chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setWidth(20);

    //Setting secondary value axis Number format
    chart.getAxes().getSecondaryVerticalAxis().isNumberFormatLinkedToSource(false);
    chart.getAxes().getSecondaryVerticalAxis().setDisplayUnit(DisplayUnitType.Hundreds);
    chart.getAxes().getSecondaryVerticalAxis().setNumberFormat ("0.0%");

    //Setting chart maximum, minimum values
    chart.getAxes().getSecondaryVerticalAxis().isAutomaticMajorUnit(false);
    chart.getAxes().getSecondaryVerticalAxis().isAutomaticMaxValue(false);
    chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinorUnit(false);
    chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinValue(false);

    chart.getAxes().getSecondaryVerticalAxis().setMaxValue(20f);
    chart.getAxes().getSecondaryVerticalAxis().setMinValue(-5f);
    chart.getAxes().getSecondaryVerticalAxis().setMinorUnit(0.5f);
    chart.getAxes().getSecondaryVerticalAxis().setMajorUnit(2.0f);


    //Setting chart back wall color
    chart.getBackWall().setThickness(1);
    chart.getBackWall().getFormat().getFill().setFillType(FillType.Solid);
    chart.getBackWall().getFormat().getFill().getSolidFillColor().setColor(Color.WHITE);

    chart.getFloor().getFormat().getFill().setFillType(FillType.Solid);
    chart.getFloor().getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);
    //Setting Plot area color
    chart.getPlotArea().getFormat().getFill().setFillType(FillType.Solid);
    chart.getPlotArea().getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.LightCyan));

    //Save Presentation
    pres.save("data/AsposeFormattedChart.pptx", SaveFormat.Pptx);
    System.out.println("Done");
  }
View Full Code Here

public class AsposeCreateTable
{
  public static void  main(String[] args)
  {
        //Instantiate Presentation class that represents PPTX file
        Presentation pres = new Presentation();

        //Access first slide
        ISlide sld = pres.getSlides().get_Item(0);
       
        //Define columns with widths and rows with heights
        double[] dblCols = { 50, 50, 50 };
        double[] dblRows = { 50, 30, 30, 30, 30 };
        //Add table shape to slide
        ITable tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);

        //Set border format for each cell

        for(int row = 0; row < tbl.getRows().size(); row++)
        {
            for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++)
            {
                tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(FillType.Solid);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(Color.RED);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5);

                tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(FillType.Solid);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(Color.RED);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5);

                tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(FillType.Solid);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(Color.RED);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5);

                tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(FillType.Solid);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(Color.RED);
                tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5);
            }
        }
        //Merge cells 1 & 2 of row 1
        tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(0), false);

        //Add text to the merged cell
        tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells");

        //Save PPTX to Disk
        pres.save("data/AsposeTable.pptx", SaveFormat.Pptx);
        System.out.println("Program executed successfully");
  }
View Full Code Here

public class AsposeUpdateExistingChart
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents PPTX file//Instantiate Presentation class that represents PPTX file
    Presentation pres = new Presentation("data/AsposeChart.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("data/AsposeChartModified.pptx", SaveFormat.Pptx)
    System.out.println("Done");

  }
View Full Code Here

public class AsposeDeleteSlides
{
  public static void main(String[] args)
  {
    //Instantiate a PresentationEx object that represents a PPTX file
    Presentation pres = new Presentation("data/presentation.pptx");

    pres.getSlides().removeAt(1); //Removing a slide using its index

    //===========================================================
    //Accessing a slide using its index in the slides collection
    ISlide slide = pres.getSlides().get_Item(0);
    pres.getSlides().remove(slide); //Removing a slide using its reference

        //Writing the presentation as a PPTX file
        pres.save("data/DeleteSlides_Aspose.pptx", SaveFormat.Pptx);

        //Printing the status
        System.out.println("Slide removed successfully!");
  }
View Full Code Here

public class AsposeAddBackground
{
  public static void  main(String[] args) throws Exception
  {
    //Instantiate the Presentation class that represents the presentation file
    Presentation pres = new Presentation();

    //Set the background with Image
    pres.getSlides().get_Item(0).getBackground().setType (BackgroundType.OwnBackground);
    pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType ( FillType.Picture);
    pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode( PictureFillMode.Stretch);

    //Set the picture
    IPPImage imgx =null;
    imgx = pres.getImages().addImage(new FileInputStream(new File("data/background.jpg")));

    //Image imgx = pres.getImages().addImage(image);
    //Add image to presentation's images collection

    pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage (imgx);

    //Write the presentation to disk
    pres.save("data/AsposeBG.pptx",SaveFormat.Pptx);
  }
View Full Code Here

TOP

Related Classes of com.aspose.slides.Presentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.