This article demonstrates how to hide or show comments in an Excel file using Spire.XLS for Java.
The sample Excel file:
import com.spire.xls.ExcelVersion; import com.spire.xls.Workbook; import com.spire.xls.Worksheet; public class HideOrShowComments { public static void main(String[] args){ //Create a Workbook instance Workbook workbook = new Workbook(); //Load the sample Excel file workbook.loadFromFile("CommentExample.xlsx"); //Get the first worksheet Worksheet sheet = workbook.getWorksheets().get(0); //Hide the first and the second comments sheet.getComments().get(0).isVisible(false); sheet.getComments().get(1).isVisible(false); //Show the third comment sheet.getComments().get(2).isVisible(true); //Save the result file workbook.saveToFile("HideOrShowComment.xlsx", ExcelVersion.Version2013); } }
The output Excel file: