Ask Your Question
0

Need LO BASIC Reference for Cell & Sheet Properties

asked 2013-06-04 00:52:30 +0100

C A J gravatar image

updated 2015-08-28 22:54:13 +0100

Alex Kemp gravatar image

I wrote my first Calc macro today (and yesterday) and was immensely frustrated at not finding a reference source for the cell and sheet object properties. I am attempting to create a blank sheet and copy its general framework from another sheet in the same .xlsx file. Fortunately, Record Macro helped my create the new sheet (or I would have been completely lost), but was ineffective at dealing with any formatting. I realize the Record feature is acknowledged as very unreliable.

I was able to get data copied from the reference sheet with .formula and I finally found the right property names to get these cell formatting attributes (though the naming choices seems wildly divergent from broader practice):

Cell1 = Sheet1.GetCellbyPosition(iCol, iRow)
Cell2 = Sheet2.GetCellbyPosition(iCol, iRow)
Cell2.Formula       = Cell1.Formula
Cell2.CharFont      = Cell1.CharFont
Cell2.CharHeight    = Cell1.CharHeight  'font size
Cell2.CharWeight    = Cell1.CharWeight  '+/- bold
Cell2.CharPosture   = Cell1.CharPosture '+/- italic
Cell2.CharUnderline = Cell1.CharUnderline   '+/- underscore
Cell2.NumberFormat  = Cell1.NumberFormat

It took me many hours to ferret out the arcane property names and I still have quite a few yet to resolve, including:

How to set column widths from template sheet.
How to set row heights from template sheet.
How to set cell WrapText property from template sheet.
How to set cell text justification (left, right, center) from template sheet.
How to set page orientation (portrait/landscape) from template sheet.
How to set page header on/off from template sheet.
How to set page margin from template sheet.
How to set fit-to-page from template sheet.

So here's my question: Where can I find a reference document for LO Calc version 4 that shows the cell and sheet property names?

It doesn't have to be fancy.

Thanks.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
0

answered 2015-01-22 20:45:05 +0100

There are documents to help at The Document Foundation page on Macros. The full api is available at the Libre Office API web site. If you want to see examples then Basic examples should help in the first instance.

I found that the best reference is Andrew Pitonyak's book available via The Document Foundation page on Macros. The biggest help while coding is the X-ray tool mentioned on the same page. It saves hours of searching for what is available.

I have just noted the date on this question and can only apologise for not noticing this before. I hope you have managed to find your answer by now. I have answered this so that everything is there for others researching the same question.

edit flag offensive delete link more
0

answered 2018-08-22 13:38:18 +0100

Orpheus2000 gravatar image

updated 2018-08-22 13:39:27 +0100

"I found that the best reference is Andrew Pitonyak's book available via The Document Foundation page on Macros. The biggest help while coding is the X-ray tool mentioned on the same page. It saves hours of searching for what is available"

I couldn't get anywhere with the X-RAY link this seems to refer to. Perhaps it's out of date. Neither could I find a comprehensive reference in Andrew's book "Macros Explained", but then maybe I'm looking in the wrong place.

edit flag offensive delete link more

Comments

It might be that you didn't swallow completely the most important role of the API in custom programming for LibreOffice. In Excel-VBA nearly(?) every subcomponent (object) living in the document is mapped to something looking roughly like elements of the language Basic (VBA). For LibO Basic is just a (simple!) programming language, and relevant things need to be done via the ApplicationProgrammingInterface. Only very few objects and structures are "integrated" in Basic.

Lupp gravatar imageLupp ( 2018-08-22 14:37:50 +0100 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-04 00:52:30 +0100

Seen: 5,145 times

Last updated: Aug 22 '18