Skip to content

Not able to set ComProperty with arguments #1073

@joerg1985

Description

@joerg1985

Provide complete information about the problem

  1. Version of JNA and related jars: 5.2.0
  2. Version and vendor of the java virtual machine: openjdk 11.0.2
  3. Operating System: Windows 10
  4. System architecture (CPU type, bitness of the JVM): x64
  5. Complete description of the Problem:

Setting a ComProperty with arguments allways only takes the first Argument.

We try to call this https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.irange.value as a ComProperty.

The IDL definition of this property is:
[propget, helpcontext(0x00023358)]
HRESULT _stdcall Value(
[in, optional] VARIANT RangeValueDataType,
[in, lcid] long lcid,
[out, retval] VARIANT* RHS);
[propput, helpcontext(0x00023358)]
HRESULT _stdcall Value(
[in, optional] VARIANT RangeValueDataType,
[in, lcid] long lcid,
[in] VARIANT RHS);

The JNA bindings are:

@ComProperty(name = "Value")
Object getValue(Object RangeValueDataType);

@ComProperty(name = "Value")
void setValue(Object RangeValueDataType, Object value);

I tryed to call it like this, but the cell is still empty:
range.setValue(Variant.VARIANT_MISSING, "test");

I tryed to call it like this, but the cell is filled with "10":
range.setValue(10, "test");

While debugging if found the following lines in ProxyObject#invoke, ignoring all the args with index > 0. i think this might be the reason for this.
if(dispId != -1) {
this.setProperty(new DISPID(dispId), args[0]);
return null;
} else {
String propName = this.getMutatorName(method, prop);
this.setProperty(propName, args[0]);
return null;
}

  1. Steps to reproduce:
    I could provide an example running Excel 2016 and setting a cell, if needed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions