我创建了一个包含隐藏工作表的 excel 2007 工作簿。有一个未隐藏的工作表具有命令按钮,每个命令按钮上都有每个工作表名称。单击命令按钮时,应使隐藏的工作表可见,并且应将焦点放在该工作表上。下面的代码返回此错误:
非静态字段、方法或属性“Microsoft.Office.Tools.Excel.WorksheetBase.Visible get”需要对象引用
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Microsoft.Office.Tools.Excel;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
namespace TestProj
{
public partial class Sheet17
{
private void Sheet17_Startup(object sender, System.EventArgs e)
{
}
private void Sheet17_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Startup += new System.EventHandler(this.Sheet17_Startup);
this.Shutdown += new System.EventHandler(this.Sheet17_Shutdown);
}
#endregion
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Sheet5 How = new Sheet5();
How.Visible = Excel.XlSheetVisibility.xlSheetVisible;
}
}
}
有人可以帮我解决这个错误吗?