原創|使用教程|編輯:王香|2017-09-30 13:49:12.000|閱讀 432 次
概述:Spire.XLS 是一個專業的Excel控件,有 .NET、WPF和Silverlight 版本,通過Spire.XLS無需安裝微軟Excel,也能擁有Excel的全套功能,本文介紹了如何通過Spire.XLS 在C#中隱藏或顯示Excel注釋。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
在有些時候,我們可能需要在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 comment sheet.Comments[0].IsVisible = false; //Show comment //sheet.Comments[0].IsVisible = true;
Step 4:保存文檔
workbook.SaveToFile("HideComment.xlsx", ExcelVersion.Version2013);
截圖:
完整代碼:
//Instantiate a Workbook instance and load the excel document Workbook workbook = new Workbook(); workbook.LoadFromFile("Comments.xlsx"); //Get the first worksheet Worksheet sheet = workbook.Worksheets[0]; //Hide the specific comment in the worksheet sheet.Comments[0].IsVisible = false; //Show the specific comment in the worksheet //sheet.Comments[0].IsVisible = true; //Save the document workbook.SaveToFile("HideComment.xlsx", ExcelVersion.Version2013);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn