VSTO 中的特殊单元 [英] SpecialCells in VSTO
本文介绍了VSTO 中的特殊单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 VSTO 项目中使用针对 3.5 框架和 Excel2007 的 C# 使用 SpecialCells 方法.
I'm trying to use the SpecialCells method in a VSTO project using c# against the 3.5 framework and Excel2007.
这是我的代码:
Excel.Worksheet myWs = (Excel.Worksheet)ModelWb.Worksheets[1];
Range myRange = myWs.get_Range("A7", "A800");
//Range rAccounts = myRange.SpecialCells(XlCellType.xlCellTypeConstants, XlSpecialCellsValue.xlTextValues);
Range rAccounts = myWs.Cells.SpecialCells(XlCellType.xlCellTypeConstants, XlSpecialCellsValue.xlTextValues);
当我运行它时,它抛出一个异常......
When I run this, it throws an exception...
System.Exception._COMPlusExceptionCode with a value of -532459699
请注意,如果我切换(取消注释一个并注释另一个)上面的 Range rAccounts 行,我会得到相同的异常.
Note that I get the same exception if I switch (uncomment one and comment the other) the above Range rAccounts line.
推荐答案
我想通了...工作表受到保护!
I figured it out... the worksheet was protected!
myWs.Unprotect(Properties.Settings.Default.PasswordSheet);
修复它......对于那些在家玩耍的人......完成后不要忘记保护床单.
fixes it...for those playing along at home...don't forget to protect the sheet when you're done.
myWs.Protect(Properties.Settings.Default.PasswordSheet, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
这篇关于VSTO 中的特殊单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文