[英]Modify excel appearance with c# in winform application
I have a winform application that contains an excel viewer in one of its forms.It lets user to open and modify excel files. 我有一个winform应用程序,其中包含一种形式的excel查看器,它使用户可以打开和修改excel文件。 but i want to avoid users to create any new sheets, 但我想避免用户创建任何新的工作表,
so i need to know : 所以我需要知道:
How can i get rid of the last tab of workbook tabs that allows user to add new sheet? 如何摆脱允许用户添加新工作表的工作簿标签的最后一个标签?
Edit : 编辑:
I have found the following code to unvisible the button in the above image: 我发现以下代码使上图中的按钮不可见:
ExcelViewer1.Application.CommandBars["Workbook tabs"].Controls["Sheet List"].Visible = false;
But it thrown a COMException : " Error HRESULT E_FAIL has been returned from a call to a com component ". 但是它引发了COMException:“ 从对com组件的调用中返回了错误HRESULT E_FAIL ”。
The same command works for other commandbars like Ply , Cell 相同的命令适用于其他命令栏,例如Ply , Cell
We can disable the functionality of sheet insert tab by doing something like this 我们可以通过执行以下操作来禁用工作表插入标签的功能
workbook.Protect(Type.Missing, true, true);
also you could take a look at the following link Check this link 您也可以看看以下链接检查此链接
Hope this helps 希望这可以帮助
Well, you may try this Link to add control to your Workbook then 好吧,您可以尝试使用此链接向您的工作簿添加控件,然后
add a sheet using this piece of code 使用这段代码添加工作表
Excel.Worksheet newWorksheet;
newWorksheet = (Excel.Worksheet)Globals.ThisWorkbook.Worksheets.Add(
missing, missing, missing, missing);
hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.