Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


Another hint, which you'll also find sooner or later when following the
link I provided, is the Xray tool. It's great for investigating objects.


I went the other way around, I started writing macros in OpenOffice.org
Calc (then LibreOffice Calc, then Apache OpenOffice and now LibreOffice
Calc again) and now I'm also writing macros in Excel at work (I run 100 %
Linux at home so no Excel there). There are some similarities but the
differences are also huge. Some things are easier in Excel and some things
are easier in LibreOffice/Apache OpenOffice.

Here are some really basic examples about working vill cell values:
Option Explicit

Dim MyString As String, Col As Long, Row As Long
Row=3
Col=9
' You can refer to sheets and cells by names or position. the following two
lines can be equivalent:
MyString=ThisComponent.Sheets.getByName("Data").getCellByPosition(Col,Row).getString()
MyString=ThisComponent.Sheets.getByIndex(2).getCellRangeByName("J4").getString()

' The other way around:
ThisComponent.Sheets.getByName("Data").getCellByPosition(Col,Row).setString(MyString)
ThisComponent.Sheets.getByIndex(2).getCellRangeByName("J4").setString(MyString)

Also available are .setFormula(), .setValue(), getFormula() and getValue().

Of course you can make the lines shorted like these examples:

' Example 1
Dim Sheet As Object, Cell As Object
Sheet=ThisComponent.Sheets.getByName("Data")
Cell=Sheet.getCellByPosition(Col,Row)
MyString=Cell.getString()

' Example 2
Dim MyFormula As String
With ThisComponent.Sheets.getByName("Data")
MyString=.getCellByPosition(Col,Row).getString()
MyFormula=.getCellByPosition(Col,Row).getFormula()
End With



Kind regards

Johnny Rosenberg



2017-04-20 22:53 GMT+02:00 Johnny Rosenberg <gurus.knugum@gmail.com>:

2017-04-18 15:40 GMT+02:00 Martini <martini.forum@gmail.com>:

Hi,

First of all, I'm using libreoffice 5.2.6.

I've made some macros with Excel in my days but never used Calc and never
interfaced with another application (Word or Writer) so I'm pretty lost
here.

I'd like to generate a text document using data from Calc.
Here's an anonymized example of a Calc file: https://ufile.io/yt27b
Here is the end result Id like to generate: https://ufile.io/j3e87



You can see column BCDE are meant to be a sort of paragraph header, F2:M2
are to be included if the cell is ticked, N contains a brief explanation
of
the case.


Again, never used Calc for macros so I'll need basic training


Thanks for your help.



I would start by visiting this page:
http://www.pitonyak.org/oo.php


Kind regards

Johnny Rosenberg




--
View this message in context: http://nabble.documentfoundati
on.org/Creating-a-text-document-from-a-Calc-spreadsheet-tp4212734.html
Sent from the Users mailing list archive at Nabble.com.

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-uns
ubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted




-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.