Get and Put data into Libreoffice Calc

I have no problems talking to excel from CAD or having excel draw objects in CAD. Acad and Bricscad use a get application object. I dont have Libreoffice Calc at moment, but have found some information about opening the link between the two programs.

Has any one got the 2 way talking to work ? Using VL not .net.

The link seems based around this ("com.sun.star.bridge.OleObjectFactory")

Comments

  • There seems not to be much information on this topic.

    I could find a few articles (not all in english) with some references about how to connect from Calc to Autocad, using StarBasic.
    https://forums.autodesk.com/t5/vba/interconnection-between-autocad-and-libreoffice-calc-via-vba/td-p/9734036
    https://cadxp.com/topic/43274-connection-libre-office-calc-et-autocad/
    https://www.redchar.net/pages/?x=libreoffice-scrivere-dwg

    Regarding the reverse connection, I could only find this old forum post, but there is nothing specific.
    https://forum.bricsys.com/discussion/21458/libreoffice-calc-link-to-bricscad
  • Thank you very much there is a lot of information out there just a case of working out the equivalent to the excel code I have. Please find attached something I have put together multi functions for Excel so will make equivalent for Libre Calc. Working out the opening link is much clearer now.

  • Hi,

    Just also having a look into this one too.

    So far I have created a new spreadsheet using the following...
    
    (setq *star-SM* (vlax-get-or-create-object "com.sun.star.ServiceManager"))
    (setq *star-CR* (vlax-invoke-method *star-SM* "createInstance" "com.sun.star.reflection.CoreReflection" ))
    (setq *star-desktop* (vlax-invoke-method *star-SM* "createInstance" "com.sun.star.frame.Desktop" ))
    
    (defun star-calc-new ()
      (vlax-invoke-method *star-desktop* "loadComponentFromURL" "private:factory/scalc" "_blank" (vlax-make-variant 0 vlax-vbLong) (vlax-make-variant (vlax-make-safearray vlax-vbVariant '(0 . 0))) )
      )
    
    (setq calc-new (star-calc-new))
    
    Got an issue with loading an existing file that I am still working on...

  • Figured out the loading of an existing file - just needed to get the URL in the correct format.

    Also, Check this link out for more info.
    ODF Spreadsheet Wiki

    Hope this helps.
  • I am using Bricscad there is a lot more info over at CADTUTOR.

    This is a more extensive example as posted at Cadtutor. https://www.cadtutor.net/forum/topic/79565-autocad-use-libreoffice-instead-of-excel/page/3/#comment-631694

    It uses VBA which is called via lisp.

    Thanks Tim, I will look at converting the rest of the code to VL. In particular the Get & Put cells.

    This should be converted possiby for get and put
    xCell = xRange.getCellByPosition(0, 0);
    // Set cell value.
    xCell.setValue(1234);

    Its very much about working out functions, have a look at my Excel functions, very much helped out by others.


  • With getting and setting data into cells you can also get/set an entire range in one go - instead of cell by cell...
    by using getCellRangeByPosition method to get the range object from the sheet object and getDataArray method on the range object.
    Just have to then disassemble the dataArray to a Lisp Data array - it is all made up of variants of different types.

    Setting it is pretty much the same in reverse - building the dataArray variant from Lisp data and using the setDataArray method on a range object of the right size for the lisp data...
  • The biggest problem I have at the moment is finding correct syntax compared to Excel code. For majority of the time I am playing with single cells, up to a full existing range which I have excel code for. As posted for any one to ahve a look at.

    For the moment I am very happy with the responses so when I return to the task I am sure will ask more questions.