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

  Reveal hidden contents

 

  • 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
  On 2/6/2024 at 9:07 PM, GMK said:

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

Expand  

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
  On 1/12/2024 at 2:09 PM, donnyh13 said:

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

Expand  

setDataArray is supposed to insert both numbers and strings:

  Quote
Expand  

 

Posted (edited)
  On 2/8/2024 at 8:13 PM, GMK said:

setDataArray is supposed to insert both numbers and strings:

Expand  

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

Best wishes,

Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

  Reveal hidden contents

 

Posted
  On 2/8/2024 at 8:07 PM, 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?

Expand  

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

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...