This article demonstrates how to add shadow effects to shapes in PowerPoint by using Spire.Presentation for Java. In addition to the PresetShadowEffect shown in this article, you can also add InnerShadowEffect, OuterShadowEffect and SoftEdgeEffect, etc.

import com.spire.presentation.*;
import com.spire.presentation.drawing.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;

public class setShadowEffect {
    public static void main(String[] args) throws Exception {

        //Create a Presentation instance
        Presentation ppt = new Presentation();

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Add a shape to the slide.
        Rectangle2D rect = new Rectangle2D.Float(120, 100, 150, 300);
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, rect);

        //Fill the shape with a picture
        shape.getFill().setFillType(FillFormatType.PICTURE);
        shape.getFill().getPictureFill().getPicture().setUrl("https://cdn.e-iceblue.com/C:\\Users\\Administrator\\Desktop\\img.png");
        shape.getLine().setFillType(FillFormatType.NONE);
        shape.getFill().getPictureFill().setFillType(PictureFillType.STRETCH);

        //Set shadow effect
        PresetShadow presetShadow = new PresetShadow();
        presetShadow.setPreset(PresetShadowValue.BACK_RIGHT_PERSPECTIVE);
        presetShadow.getColorFormat().setColor(Color.lightGray);

        //Apply the shadow effect to shape
        shape.getEffectDag().setPresetShadowEffect(presetShadow);

        //Save the document
        ppt.saveToFile("output/ShapeShadow.pptx", FileFormat.PPTX_2013);
    }
}

Add Shadow Effects to Shapes in PowerPoint in Java

This article demonstrates how to detect merged cells in an Excel worksheet and unmerge the merged cells using Spire.XLS for Java.

The input Excel file:

Detect Merged Cells in an Excel Worksheet in Java

import com.spire.xls.CellRange;
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class DetectMergedCells {
    public static void main(String[] args) throws Exception {
        //Create a Workbook instance
        Workbook workbook = new Workbook();
        //Load the Excel file
        workbook.loadFromFile( "Input.xlsx");

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the merged cell ranges in the first worksheet and put them into a CellRange array
        CellRange[] range = sheet.getMergedCells();

        //Traverse through the array and unmerge the merged cells
        for(CellRange cell : range){
            cell.unMerge();
        }
        
        //Save the result file
        workbook.saveToFile("DetectMergedCells.xlsx", ExcelVersion.Version2013);
    }
}

The output Excel file:

Detect Merged Cells in an Excel Worksheet in Java

Hyperlinks are useful features in Excel documents, providing quick access to other relevant resources such as websites, email addresses, or specific cells within the same workbook. However, sometimes you may want to modify or delete existing hyperlinks for various reasons, such as updating broken links, correcting typos, or removing outdated information. In this article, we will demonstrate how to modify or delete hyperlinks in Excel in Java using Spire.XLS for Java library.

Install Spire.XLS for Java

First of all, you're required to add the Spire.Xls.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls</artifactId>
        <version>15.12.15</version>
    </dependency>
</dependencies>

Modify Hyperlinks in Excel in Java

If there are issues with the functionality of a hyperlink caused by damage or spelling errors, you may need to modify it. The following steps demonstrate how to modify an existing hyperlink in an Excel file:

  • Create an instance of Workbook class.
  • Load an Excel file using the Workbook.loadFromFile() method.
  • Get a specific worksheet using the Workbook.getWorksheets().get() method.
  • Get the collection of all hyperlinks in the worksheet using the Worksheet.getHyperLinks() method.
  • Change the values of TextToDisplay and Address property using the HyperLinksCollection.get().setTextToDisplay() and HyperLinksCollection.get().setAddress method.
  • Save the result file using the Workbook.saveToFile() method.
  • Java
import com.spire.xls.*;
import com.spire.xls.collections.HyperLinksCollection;

public class ModifyHyperlink {
    public static void main(String[] args) {
        //Create a Workbook instance
        Workbook workbook = new Workbook();

        //Load an Excel file
        workbook.loadFromFile("Sample.xlsx");

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the collection of all hyperlinks in the worksheet
        HyperLinksCollection links = sheet.getHyperLinks();

        //Change the values of TextToDisplay and Address property
        links.get(0).setTextToDisplay("Republic of Indonesia");
        links.get(0).setAddress("https://www.indonesia.travel/gb/en/home");

        //Save the document
        workbook.saveToFile("ModifyHyperlink.xlsx", ExcelVersion.Version2013);
        workbook.dispose();
    }
}

Java: Modify or Delete Hyperlinks in Excel

Delete Hyperlinks from Excel in Java

Spire.XLS for Java also offers the Worksheet.getHyperLinks().removeAt() method to remove hyperlinks. The following are the steps to delete hyperlink from Excel in Java.

  • Create an instance of Workbook class.
  • Load an Excel file using the Workbook.loadFromFile() method.
  • Get a specific worksheet using the Workbook.getWorksheets().get() method.
  • Get the collection of all hyperlinks in the worksheet using the Worksheet.getHyperLinks() method.
  • Remove a specific hyperlink and keep link text using the Worksheet.getHyperLinks().removeAt() method.
  • Save the result file using the Workbook.saveToFile() method.
  • Java
import com.spire.xls.*;
import com.spire.xls.collections.HyperLinksCollection;

public class RemoveHyperlink {
    public static void main(String[] args) {
        //Create a Workbook instance
        Workbook workbook = new Workbook();

        //Load an Excel file
        workbook.loadFromFile("Sample.xlsx");

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the collection of all hyperlinks in the worksheet
        HyperLinksCollection links = sheet.getHyperLinks();

        //Remove the first hyperlink and keep link text
        sheet.getHyperLinks().removeAt(0);

        //Remove all content from the cell
        //sheet.getCellRange("A7").clearAll();

        //Save the document
        String output = "RemoveHyperlink.xlsx";
        workbook.saveToFile(output, ExcelVersion.Version2013);
        workbook.dispose();
    }
}

Java: Modify or Delete Hyperlinks in Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

page 39