Jump to content

Recommended Posts

Posted

Hi all,

I noticed when I use

$saveResult = _OOoCalc_BookSaveAs($oCalc, $savePath & $saveFilename, "MS Excel 97", True),

it doesn't set the current working directory for Open Office. How do I set it so that using the file open menu in OO brings me to my $savepath?

  • 1 month later...
Posted

Hi,

we seem to have a problem with the UDF not properly inserting values into a Calc sheet.

We use the WriteFromArray Function but all numbers are displayed as text and when I switch the celltype manualy a ' is inserted before the value. 

We allready tried to switch the numberformat (decimal point to comma) und unsing a template, but both didn't help. Any way we can force numbers as numbers?

Posted (edited)

@Starocotes, Until GMK gets back to you.

Edit* — I was wrong.

As a temporary fix, you could change the line used in _OOoCalc_WriteFromArray from this:

$oRange.setDataArray($avOOoArray)

To this:

$oRange.setData($avOOoArray)

 

setDataArray inserts data as strings. SetData inserts (and supports) only numbers.

Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

  • 4 weeks later...
Posted

Sorry @Starocotes.  I didn't even see your comment until now.  Do you have an example--some code that you could produce that shows the issue?

Posted
Func __export2OO(byref $bOoTemplate, byref $sOoTemplateFileName, byref $sOoTemplateStartCell, byref $sOutFileName, byref $oQuery)
    Local $oCalc = _OOoCalc_BookNew(False)
    $RC = _OOoCalc_WriteFromArrayDirect($oCalc, __SQLQuery2Array($oQuery), $sOoTemplateStartCell,-1,-1,False,'~') ;Writes the array at the cell
    $RC = _OOoCalc_BookSaveTo($oCalc, $sOutFileName, $sSaveType)
    _OOoCalc_BookClose($oCalc)
EndFunc

That's basically it. The $oQuery is getting Data from an MS SQL Database.

Posted
14 hours ago, GMK said:

Are you using LibreOffice or OpenOffice and which version, please?

Version: 7.5.9.2 (X86_64) / LibreOffice Community
Build ID: cdeefe45c17511d326101eed8008ac4092f278a9
CPU threads: 4; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded

Posted

I'll have to play around with it at home this evening.  In the meantime, is it possible to loop through an array from __SQLQuery2Array and get all the data types to see if it's what you're expecting?

Posted (edited)
4 hours ago, GMK said:

setDataArray is supposed to insert both numbers and strings:

You're right GMK, my apologies. I had that mixed up with Formulas not inserting correctly using that.

I'm guessing you are correct, I bet the values are being returned as strings from in the SQL array.

Best wishes,

Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Posted
15 hours ago, GMK said:

I'll have to play around with it at home this evening.  In the meantime, is it possible to loop through an array from __SQLQuery2Array and get all the data types to see if it's what you're expecting?

You are right, they are all strings. 

Now I have to figure out how to get the REAL fieldtypes.

Posted

Okay, I found this one problem ans fixed it. Not the array contains int32 and double values no strings anymore. 

But the the output in LibreOffice is still considered a string I guess it has something to do with the localisation and the different handling of "." and ",".

Posted

If you changed that one line in _OOoCalc_WriteFromArray earlier, you may want to change it back.

Posted
On 2/9/2024 at 10:17 PM, GMK said:

If you changed that one line in _OOoCalc_WriteFromArray earlier, you may want to change it back.

No I did not change that line. 

It sill is rendered as Text

"<text:p>1.77</text:p>"

 

Posted

The problem seems to be the way I call _OOoCalc_WriteFromArrayDirect

$RC = _OOoCalc_WriteFromArrayDirect($oCalc, __SQLQuery2Array($oQuery), $sOoTemplateStartCell,-1,-1,False,'~') ;Writes the array at the cell

The ~ as the last parameter converts the whole array into strings.

$RC = _OOoCalc_WriteFromArrayDirect($oCalc, __SQLQuery2Array($oQuery), $sOoTemplateStartCell,-1,-1,False) ;Writes the array at the cell

Finaly works.
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...