【使用教程】Spire.XLS 教程:在C#中隐藏或显示Excel注释

来源:互联网 发布:微信群淘宝优惠券提成 编辑:程序博客网 时间:2024/05/29 08:55

在有些时候,我们可能需要在Excel文档中显示或隐藏注释,本文介绍如何使用Spire.XLS隐藏或显示Excel文档中的现有注释。

详细步骤:

Step 1:实例化一个Workbook实例并加载excel文档

Workbook workbook = new Workbook();workbook.LoadFromFile("Comments.xlsx");

Step 2:获取第一个工作表

Worksheet sheet = workbook.Worksheets[0];

Step 3:隐藏或显示工作表中的具体注释

//Hide commentsheet.Comments[0].IsVisible = false; //Show comment//sheet.Comments[0].IsVisible = true;

Step 4:保存文档

workbook.SaveToFile("HideComment.xlsx", ExcelVersion.Version2013);

截图:

图片1

完整代码:

//Instantiate a Workbook instance and load the excel documentWorkbook workbook = new Workbook();workbook.LoadFromFile("Comments.xlsx"); //Get the first worksheetWorksheet sheet = workbook.Worksheets[0]; //Hide the specific comment in the worksheetsheet.Comments[0].IsVisible = false; //Show the specific comment in the worksheet//sheet.Comments[0].IsVisible = true; //Save the documentworkbook.SaveToFile("HideComment.xlsx", ExcelVersion.Version2013);

点击下载Spire.XLS

阅读全文
0 0