本文介绍如何使用Spire.XLS for Java隐藏或显示Excel中的网格线。
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
public class HideOrShowGridlines {
public static void main(String[] args) {
//创建Workbook对象
Workbook workbook = new Workbook();
//加载Excel文档
workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.xlsx");
//获取第一个工作表
Worksheet worksheet = workbook.getWorksheets().get(0);
//隐藏网格线
worksheet.setGridLinesVisible(false);
////显示网格线
//worksheet.setGridLinesVisible(true);
//保存文档
workbook.saveToFile("HideGridlines.xlsx", ExcelVersion.Version2016);
}
}
隐藏网格线