Recent

Author Topic: Insert variant array to excel range  (Read 3065 times)

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: Insert variant array to excel range
« Reply #15 on: May 28, 2023, 01:28:28 am »
All strings past to the OLEVariant for the automation is suppose to be WideString.

 The compiler will automatically make constant strings a UTF8 string etc.
 
 Most if not all of Office Automation requires widestring.

 
MyOldVariant := 'My text' will end up a UTF8, not a wide string.

 I suppose earlier versions of the compiler during the bronze age may have known this for OLEVariants and did it correctly, but since the compiler is in full swing of UTF8, it appears things maybe getting in the way.

 Those are my assumptions, I normally type cast everything using Fpc.
The only true wisdom is knowing you know nothing

TRon

  • Hero Member
  • *****
  • Posts: 3660
Re: Insert variant array to excel range
« Reply #16 on: May 28, 2023, 11:36:03 am »
It also happens when all variables are olevariant, so apparently someting in the runtime or compiler still returns variant intermediate results.
Thank you for testing. In theory that should have worked even though I do not know what range.value type is expected to be (yes an OLEvariant array but which exact element type).

As far as know, OleVariant has always been the requirement, even with Delphi as long as I remember!
Yes you are correct. the 'problem' however is that at one point things worked using 'normal' variants. It seems that this notion is persistent (no idea why).

All strings past to the OLEVariant for the automation is suppose to be WideString.
Also correct. Does this thread not mention that to be addressed ?

edit: Some other mention of variant vs OLEvariant, vararraycreate and string types.
« Last Edit: May 28, 2023, 12:15:16 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Nicole

  • Hero Member
  • *****
  • Posts: 1009
Re: Insert variant array to excel range
« Reply #17 on: June 07, 2023, 08:09:05 pm »
an off topic hint:
I worked a lot with Excel, import, export, OLE and much more.
This kept me busy for hours, days an weeks and the results were not robust. Never.

I gave up and am that glad to have got rid of all this mess.

Excel is outdated in matter of stability.
Did you follow the disaster of the Austrian vote of the SPÖ? - greetings from an Excel link.

 

TinyPortal © 2005-2018