We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OaIdlUtil#toPrimitive fails to correctly calculate the raw index positions if the dimension bounds are not zero based.
This manifests when querying ranges from excel, which return 1-based arrays.
SAFEARRAY sa = SAFEARRAY.createSafeArray(new VARTYPE(VT_I4), 2, 2); Object[][] data = (Object[][]) OaIdlUtil.toPrimitiveArray(sa, false); for(Object[] row: data) { System.out.println(Arrays.toString(row)); } sa.rgsabound[0].lLbound = new LONG(1); sa.rgsabound[1].lLbound = new LONG(1); sa.write(); System.out.println(Arrays.toString((Object[]) OaIdlUtil.toPrimitiveArray(sa, false)));
The text was updated successfully, but these errors were encountered:
A workaround (see adjustment of lLbound):
public class Main { public static void main(String[] args) { Ole32.INSTANCE.CoInitializeEx(Pointer.NULL, Ole32.COINIT_MULTITHREADED); ObjectFactory of = new ObjectFactory(); Application excel = null; try { excel = of.createObject(Application.class); Workbook wb = excel.getWorkbooks().Open("e:/temp/test.xlsx", VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING); _Worksheet ws = wb.getActiveSheet().queryInterface(_Worksheet.class); Range r = ws.getRange("A1:C1", VARIANT_MISSING); try(OaIdl.SAFEARRAY sa = (OaIdl.SAFEARRAY) r.getValue(VARIANT_MISSING)) { sa.rgsabound[0].lLbound = new LONG(0); sa.rgsabound[1].lLbound = new LONG(0); Object[][] obj = (Object[][]) OaIdlUtil.toPrimitiveArray(sa, false); for(Object[] o: obj) { System.out.println(Arrays.toString(o)); } } } finally { if (excel != null) { excel.Quit(); } of.disposeAll(); Ole32.INSTANCE.CoUninitialize(); } } }
Sorry, something went wrong.
No branches or pull requests
OaIdlUtil#toPrimitive fails to correctly calculate the raw index positions if the dimension bounds are not zero based.
This manifests when querying ranges from excel, which return 1-based arrays.
Provide complete information about the problem
The text was updated successfully, but these errors were encountered: