[Solved] Hide Rows/Columns programmatically in Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BarryGribb
Posts: 2
Joined: Fri Apr 08, 2016 9:33 pm

[Solved] Hide Rows/Columns programmatically in Calc

Post by BarryGribb »

Hey all,

I've been trying to find a way to hide rows/columns programmatically from within functions in OO Calc. Any way to do that?

I have a multi-tabbed spread sheet that I use for generated bids, packing slips, invoices, etc. They are all drawing from the same data on the first tab, and I have 30 rows to use. Right now I'm deleting the unused rows to generate the outputs from other tabs, and I'd like to find a way to automatically hide them instead.

Any ideas? I have searched around a lot, but it's a very difficult thing to search for, apparently.

Thanks in advance!

Barry
Last edited by Hagar Delest on Sat Apr 09, 2016 10:51 pm, edited 1 time in total.
Reason: tagged [Solved].
Open Office 4.1.0 on Windows 7 and Mac OSX
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Hide Rows/Columns programmatically in Calc

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
BarryGribb
Posts: 2
Joined: Fri Apr 08, 2016 9:33 pm

Re: Hide Rows/Columns programmatically in Calc

Post by BarryGribb »

Those are great, thanks. I thought it might have to be a macro, because I definitely saw no way to do it in the code within a cell. I haven't done macros, now's the time to start.
Open Office 4.1.0 on Windows 7 and Mac OSX
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Hide Rows/Columns programmatically in Calc

Post by Lupp »

It may also be of interest that there is no need to loop through the single columns and/or rows of a range for the purpose. With any 'SheetCellRange' object of a 'SpreadsheetDocument' you can do it like in the following code.

Code: Select all

myRange.Columns.IsVisible = false
myRange.Rows.IsVisible    = false
See attached demo.
Attachments
aoo82829ShowHideRange_1.ods
(11.07 KiB) Downloaded 782 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply