page 123

This article will show you how to use Spire.XLS for .NET to create a bubble chart in Excel in C# and VB.NET.

C#
using Spire.Xls;

namespace BubbleChart
{
    class Program
    {
        static void Main(string[] args)

        {
            //Create a new workbook
            Workbook workbook = new Workbook();

            //Add a worksheet and set name 
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];
            sheet.Name = "Chart data";
            //Initialize chart and set its type
            Chart chart = sheet.Charts.Add(ExcelChartType.Bubble);
            
            //Set the position of the chart in the worksheet
            chart.LeftColumn = 1;
            chart.RightColumn = 10;
            chart.TopRow = 1;
            chart.BottomRow = 20;

            //Set title for the chart and values
            Spire.Xls.Charts.ChartSerie cs1 = chart.Series.Add("Bubble Chart");
            cs1.EnteredDirectlyValues = new object[] { 2.2, 5.6 };
            cs1.EnteredDirectlyCategoryLabels = new object[] { 1.1, 4.4 };
            cs1.EnteredDirectlyBubbles = new object[] { 3, 6 };

            //Save the document to file
            workbook.SaveToFile("Output.xlsx", ExcelVersion.Version2010);
        }
    }
    
}
VB.NET
Imports Spire.Xls

Namespace BubbleChart
    
    Class Program
        
        Private Shared Sub Main(ByVal args() As String)
            'Create a new workbook
            Dim workbook As Workbook = New Workbook
            'Add a worksheet and set name 
            workbook.CreateEmptySheets(1)
            Dim sheet As Worksheet = workbook.Worksheets(0)
            sheet.Name = "Chart data"
            'Initialize chart and set its type
            Dim chart As Chart = sheet.Charts.Add(ExcelChartType.Bubble)
            'Set the position of the chart in the worksheet
            chart.LeftColumn = 1
            chart.RightColumn = 10
            chart.TopRow = 1
            chart.BottomRow = 20
            'Set title for the chart and values
            Dim cs1 As Spire.Xls.Charts.ChartSerie = chart.Series.Add("Bubble Chart")
            cs1.EnteredDirectlyValues = New Object() {2.2, 5.6}
            cs1.EnteredDirectlyCategoryLabels = New Object() {1.1, 4.4}
            cs1.EnteredDirectlyBubbles = New Object() {3, 6}
            'Save the document to file
            workbook.SaveToFile("Output.xlsx", ExcelVersion.Version2010)
        End Sub
    End Class
End Namespace

Effective screenshot of Excel Bubble chart:

Create Bubble Chart in Excel in C#/VB.NET

We have already demonstrated how to insert HTML formatted text to a Presentation slide by using Spire.Presentation for Java. This article will introduce the way to insert HTML with images to PowerPoint and each html tag will be added to the slide as a separate shape.

import com.spire.presentation.*;
import com.spire.presentation.collections.*;

public class AddHTMLWithImage {
    public static void main(String[] args) throws Exception {
        //Create an instance of presentation document
        Presentation ppt = new Presentation();
        //Get the shapes on the first slide.
        ShapeList shapes = ppt.getSlides().get(0).getShapes();
        //Add contents to shapes from HTML codes, which includes text and image.
        shapes.addFromHtml("<html><div><p>E-iceblue</p>" +
                "<p><img src='https://cdn.e-iceblue.com/C:\\Users\\Test1\\Desktop\\logo.png'/></p>" +
                "<p>Spire.Presentation for Java</p></html>");

        //Save the document
        String result = "output/insertHtmlWithImage.pptx";
        ppt.saveToFile(result, FileFormat.PPTX_2013);
    }
}

Insert HTML with images into PowerPoint in Java

This article demonstrates how to add hyperlinks to SmartArt Nodes in a PowerPoint document in C# and VB.NET using Spire.Presentation for .NET.

C#
using Spire.Presentation;
using Spire.Presentation.Diagrams;

namespace SmartArt
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();
            //Load the PowerPoint document
            ppt.LoadFromFile("SmartArt.pptx");

            //Get the first slide
            ISlide slide = ppt.Slides[0];
           
            //Get the SmartArt
            ISmartArt smartArt = slide.Shapes[0] as ISmartArt;

            //Add hyperlink to the first node of the SmartArt to link to a web page
            smartArt.Nodes[0].Click = new ClickHyperlink("https://www.e-iceblue.com");
            //Add hyperlink to the first node of the SmartArt to link to a specific slide
            smartArt.Nodes[1].Click = new ClickHyperlink(ppt.Slides[1]);

            //Save the result document
            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013);
        }
    }
}
VB.NET
Imports Spire.Presentation
Imports Spire.Presentation.Diagrams

Namespace SmartArt
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim ppt As Presentation = New Presentation()
            ppt.LoadFromFile("SmartArt.pptx")
            Dim slide As ISlide = ppt.Slides(0)
            Dim smartArt As ISmartArt = TryCast(slide.Shapes(0), ISmartArt)
            smartArt.Nodes(0).Click = New ClickHyperlink("https://www.e-iceblue.com")
            smartArt.Nodes(1).Click = New ClickHyperlink(ppt.Slides(1))
            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013)
        End Sub
    End Class
End Namespace

Output:

Add Hyperlinks to SmartArt Nodes in PowerPoint in C#, VB.NET

page 123