使用 SpreadSheetGear 在 MS Excel 中隐藏单元格包含?

发布于 2024-08-28 14:26:24 字数 33 浏览 7 评论 0原文

嘿,任何人都知道如何使用电子表格设备隐藏单元格包含。

Hey any body know how to hide cell contains using spreadsheet gear.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮坠入山谷 2024-09-04 14:26:24

您可以将 IRange.NumberFormat 设置为“;;;”使单元格的内容被隐藏。还有 IRange.FormulaHidden、IRange.Rows.Hidden、IRange.Columns.Hidden 以及可能其他我没有考虑的方法。下面是一些演示这些方法的代码:

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a new workbook and get a reference to Sheet1!A1.
            var workbook = SpreadsheetGear.Factory.GetWorkbook();
            var sheet1 = workbook.Worksheets[0];
            var a1 = workbook.Worksheets[0].Cells["A1"];
            // Put some text in A1.
            a1.Value = "Hello World!";
            // Set a number format which causes nothing to be displayed.
            //
            // This is probably the best way to hide the contents of 
            // a single cell.
            a1.NumberFormat = ";;;";
            // Set FormulaHidden to true - must set IWorksheet.ProtectContents 
            // to true for this make any difference. This will not hide values
            // in cells.
            a1.FormulaHidden = true;
            // Hide the row containing A1.
            a1.Rows.Hidden = true;
            // Hide the column containing A1.
            a1.Columns.Hidden = true;
        }
    }
}

You can set IRange.NumberFormat to ";;;" to cause the contents of a cell to be hidden. There are also IRange.FormulaHidden, IRange.Rows.Hidden, IRange.Columns.Hidden and probably other ways to approach it that I am not thinking about. Here is some code which demonstrates these approaches:

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a new workbook and get a reference to Sheet1!A1.
            var workbook = SpreadsheetGear.Factory.GetWorkbook();
            var sheet1 = workbook.Worksheets[0];
            var a1 = workbook.Worksheets[0].Cells["A1"];
            // Put some text in A1.
            a1.Value = "Hello World!";
            // Set a number format which causes nothing to be displayed.
            //
            // This is probably the best way to hide the contents of 
            // a single cell.
            a1.NumberFormat = ";;;";
            // Set FormulaHidden to true - must set IWorksheet.ProtectContents 
            // to true for this make any difference. This will not hide values
            // in cells.
            a1.FormulaHidden = true;
            // Hide the row containing A1.
            a1.Rows.Hidden = true;
            // Hide the column containing A1.
            a1.Columns.Hidden = true;
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文