Hide Gridlines in Excel Chart in Java

2020-05-25 07:11:46 Written by Koohji

This article demonstrates how to hide gridlines in an Excel chart using Spire.XLS for Java.

import com.spire.xls.*;

public class HideGridlinesInChart {

    public static void main(String[] args) {

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

        //Load an Excel file that contains data for creating chart
        workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\data.xlsx");

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

        //Add a column chart
        Chart chart = sheet.getCharts().add(ExcelChartType.ColumnClustered);
        chart.setChartTitle("Column Chart");

        //Set the chart data range
        chart.setDataRange(sheet.getCellRange("A1:C5"));
        chart.setSeriesDataFromRange(false);

        //Set the chart position
        chart.setLeftColumn(1);
        chart.setTopRow(6);
        chart.setRightColumn(8);
        chart.setBottomRow(19);

        //Hide the grid lines of chart
        chart.getPrimaryValueAxis().hasMajorGridLines(false);

        //Save the document
        workbook.saveToFile("HideGridlines.xlsx", ExcelVersion.Version2016);
    }
}

Hide Gridlines in Excel Chart in Java

Track Changes is a built-in feature in Microsoft Word which allows you to see all changes that were made to the document, and you can decide whether to accept or reject those changes. It is very useful especially when you are collaborating with multiple people on the same contracts or school assignments. In this article, you will learn how to programmatically accept or reject all tracked changes in a Word document using Spire.Doc for Java.

Install Spire.Doc for Java

First of all, you're required to add the Spire.Doc.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.doc</artifactId>
        <version>13.11.2</version>
    </dependency>
</dependencies>

Accept All Tracked Changes in a Word document

The detailed steps are as follows.

  • Create a Document instance.
  • Load a sample Word document using Document.loadFromFile() method.
  • Accept all changes in the document using Document.acceptChanges() method.
  • Save the document to another file using Document.saveToFile() method.
  • Java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;

public class AcceptTrackedChanges {
    public static void main(String[] args) {

        //Create a Document instance
        Document doc = new Document();

        //Load the sample Word document
        doc.loadFromFile("test file.docx");

        //Accept all changes in the document
        doc.acceptChanges();

        //Save the document
        doc.saveToFile("AcceptAllChanges.docx", FileFormat.Docx);
    }
}

Java: Accept or Reject Tracked Changes in Word

Reject All Tracked Changes in a Word document

The detailed steps are as follows.

  • Create a Document instance.
  • Load a sample Word document using Document.loadFromFile() method.
  • Reject all changes in the document using Document.rejectChanges() method.
  • Save the document to another file using Document.saveToFile() method.
  • Java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;

public class RejectTrackedChanges {
    public static void main(String[] args) {

        //Create a Document instance
        Document doc = new Document();

        //Load the sample Word document
        doc.loadFromFile("test file.docx");

        //Reject all changes in the document
        doc.rejectChanges();

        //Save the document
        doc.saveToFile("RejectAllChanges.docx", FileFormat.Docx);
    }
}

Java: Accept or Reject Tracked Changes in Word

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.

Java: Hide or Show Comments in Excel

2023-10-26 08:32:00 Written by Koohji

Comments in Excel are blocks of text that can be added to cells, mainly used to provide additional explanation or supplemental information about the cell contents. Users can add comments to the specific cells to better explain the data of worksheets. However, sometimes too many comments will cause visual clutter or obstruct other content. To avoid this issue, existing comments can be hidden programmatically to make the worksheet more organized and readable. Hidden comments can also be easily displayed when necessary. This article will show you how to hide or show comments in Excel using Spire.XLS for Java.

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.11.3</version>
    </dependency>
</dependencies>

Hide Comments in Excel

Spire.XLS for Java provides the Worksheet.getComments().get().isVisble() method to control the visibility of comments. You can easily hide existing comments by setting the parameter of this method to "false". The following are detailed steps to hide comments in excel.

  • Create an object of Workbook class.
  • Load a sample file from disk using Workbook.loadFromFile() method.
  • Get the desired worksheet of this file by calling Workbook.getWorksheets().get() method.
  • Hide the specific comments in this sheet by setting the parameter of the Worksheet.getComments().get().isVisble() method to "false".
  • Finally, save the result file using Workbook.savaToFile() method.
  • Java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class HideComment {
    public static void main(String[] args){

        //Create an object of Workbook class
        Workbook workbook = new Workbook();

        //Load a sample file from disk
        workbook.loadFromFile("Sample.xlsx");

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

        //Hide the first and the second comments in this sheet
        sheet.getComments().get(0).isVisible(false);
        sheet.getComments().get(1).isVisible(false);

        //Save the result file
        workbook.saveToFile("HideComment.xlsx", ExcelVersion.Version2013);
        workbook.dispose();
    }
}

Java: Hide or Show Comments in Excel

Show Comments in Excel

Hidden comments can also be easily displayed when necessary. If you want to show them again, please set the parameter of the Worksheet.getComments().get().isVisble() method to "true". The following are detailed steps of showing hidden comments in excel.

  • Create an object of Workbook class.
  • Load a sample file from disk using Workbook.loadFromFile() method.
  • Get the desired worksheet by calling Workbook.getWorksheets().get() method.
  • Show the specific comment in this sheet by setting the parameter of the Worksheet.getComments().get().isVisble() method to "true".
  • Finally, save the result file using Workbook.savaToFile() method.
  • Java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class ShowComment {
    public static void main(String[] args){

        //Create an object of Workbook class
        Workbook workbook = new Workbook();

        //Load a sample file from disk
        workbook.loadFromFile("HideComment.xlsx");

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

        //Show the first comment in this sheet
        sheet.getComments().get(0).isVisible(true);

        //Save the result file
        workbook.saveToFile("ShowComment.xlsx", ExcelVersion.Version2013);
        workbook.dispose();
    }
}

Java: Hide or Show Comments 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 46

Coupon Code Copied!

Christmas Sale

Celebrate the season with exclusive savings

Save 10% Sitewide

Use Code:

View Campaign Details