首页 \ 问答 \ Excel将列的某些值复制到另一个工作表(Excel Copy certain values of Column to another sheet)

Excel将列的某些值复制到另一个工作表(Excel Copy certain values of Column to another sheet)

我正在尝试将某些列的值复制到另一个工作表,但它不起作用。

我使用的代码是:

Worksheets("Report").Range(".Cells(x, 1)", ".Cells(x, 2)", ".Cells(x, 4)", ".Cells(x, 6)", ".Cells(x, 9):.Cells(x, 13)").Copy 

I'm trying to copy certain values of column to another sheet, but it's not working.

The code I am using is:

Worksheets("Report").Range(".Cells(x, 1)", ".Cells(x, 2)", ".Cells(x, 4)", ".Cells(x, 6)", ".Cells(x, 9):.Cells(x, 13)").Copy 

原文:https://stackoverflow.com/questions/40084250
更新时间:2023-05-06 20:05

最满意答案

你可能想要使用:

if(activity is HomeActivity) instead (activity as HomeActivity).javaClass == HomeActivity::class.java

原因是Mockito.mock(HomeActivity.java)会动态地创建一个实现 HomeActivity的类,使用SomeFooMockitoImpl.class获取HomeActivity.class作为参数来创建该HomeActivity.class实例。

你可以检查运行时模拟对象将是这样的: HomeActivity$$EnhancerByMockitoWithCGLIB$$b8254f54

和它的实际类名称:

activity.javaClass.simpleName (应该是SomeFooMockitoImpl


You probably want to use:

if(activity is HomeActivity) instead (activity as HomeActivity).javaClass == HomeActivity::class.java

The reason is Mockito.mock(HomeActivity.java) will dynamically create a class which implements HomeActivity using SomeFooMockitoImpl.class which gets HomeActivity.class as parameter to create that mocked instance.

You can check in runtime mock object will be something like: HomeActivity$$EnhancerByMockitoWithCGLIB$$b8254f54

and its actual class name by:

activity.javaClass.simpleName (should be SomeFooMockitoImpl)

相关问答

更多
  • 因为MyActivity::class返回一个KClass对象。 这是一个扩展的对象,是kotlin扩展反射功能的一部分。 由于人们还需要访问java类以实现向后兼容性,因此它作为字段java包含在KClass对象中。 Because MyActivity::class returns a KClass object. This is an extended object that is part of kotlin's expanded reflection ...
  • data class不等同于POJO,它做的不止于此,这就是它的继承受到限制的原因。 拿一个简单的POJO: public class User { private String name; private int age; public String getName() { return name; } public int getAge() { return age; } public void setName(final String name) { th ...
  • 缺省值equals您描述的实现仅存在于数据类中。 不适用于从Object继承实现的常规类,并且使对象与自身相等。 The default equals implementation you're describing exists only for data classes. Not for regular classes where the implementation is inherited from Object, and just make the object equal to itself.
  • 实例化data class与实例化“普通”Kotlin类没有什么不同。 从Java代码中,您将其实例化为Java类: Item item = new Item(1L, 2L); 仅供参考, data class是一个自动获取以下成员的类(请参阅此处的文档 ): equals() / hashCode()对; toString()形式为“MyClass(field1 = value1,field2 = value2)”; componentN()函数对应于声明顺序中的属性; 这对于解构声明很有用,例如: ...
  • 当您通过JavaPsiFacade搜索Kotlin类时,它返回light类,它是一个浅表示,它只基于类文件中的信息。 要添加PSI元素,您必须在其上调用navigationElement 。 然后,IJ将解析源代码并构建一个可以修改的完整PSI树。 但是,如果类是Kotlin类,那么navigationElement将返回一个不是从PsiClass派生的PsiClass 。 您必须使用Kotlin层次结构中的工具对其进行修改。 Kotlin中的方法实例也不是PsiMethod实例,而是KtMethod实例。 ...
  • 你可能想要使用: if(activity is HomeActivity) instead (activity as HomeActivity).javaClass == HomeActivity::class.java 原因是Mockito.mock(HomeActivity.java)会动态地创建一个实现 HomeActivity的类,使用SomeFooMockitoImpl.class获取HomeActivity.class作为参数来创建该HomeActivity.class实例。 你可以检查运行时模 ...
  • Class.kotlin应该工作。 如果它“在某些[你的]输入上崩溃”,那么我建议在这里提交一个问题。 您可以使用Class.forName(String) 。 避免编译器警告。 例如Class.forName("java.lang.Integer") 。 您可以取消警告。 您可以使用KClass.javaObjectType和KClass.javaPrimitiveType : when (type) { Double::class.javaObjectType, Double::class.ja ...
  • 这个库可能会解决您的问题https://github.com/nhaarman/mockito-kotlin 编辑:对不起,没有意识到你正在使用Java测试。 如果是一个选项,请尝试在kotlin中编写测试 this library may solve your issue https://github.com/nhaarman/mockito-kotlin EDIT: sorry, didn't realize you were using a Java test. If it's an option, ...
  • 你应该像这样模拟系统: class MockSystem : MockUp() { @Mock fun getProperty(name: String) = "tagB" } class MockTest { val m = MockSystem(); @Test fun test() { Assert.assertEquals(System.getProperty("hello"), "tagB") } } You sho ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)