[Solved] How to draw a rectangle in a spreadsheet

Discuss the spreadsheet application
Post Reply
gutee
Posts: 19
Joined: Wed Jan 09, 2019 9:12 am

[Solved] How to draw a rectangle in a spreadsheet

Post by gutee »

I have a task to make data visible, and try to draw rectangle based on strings in spreadsheet.
one example is, source table looks like :
name, scope
model1, inst1
model2, inst1/inst2

Which document I can learn how to draw shapes into the spreadsheet based on my table. the required rectangle may look like :
________________
| module1 |
| __________ |
| | module2 | |
| |_________| |
|_______________|

Thanks in advance.
Last edited by Hagar Delest on Fri Jan 11, 2019 9:32 am, edited 1 time in total.
Reason: tagged solved
OpenOffice.org.3.3.0
User avatar
keme
Volunteer
Posts: 3703
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: How to draw a rectangle in a spreadsheet

Post by keme »

Creating hierarchical framesets automatically may be possible by the use of conditional formatting.

Functionality depends on how deep you need to go, and how coherent/consistent your data is.

Not sure how good the visualization will be. Calc is not very well equipped for presentation design.

Your sig. says you are using version OOo 3.3.0. You may benefit from upgrading now. While I also stayed with 3.3 long after Apache took over, they have a stable and functional product now. Just a thought...
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: How to draw a rectangle in a spreadsheet

Post by John_Ha »

You will find much useful information in the User Guides, the Writer, Base and Calc Tutorials and the AOO Frequently Asked Questions. May I suggest you bookmark the pages.

Why not just colour the cell backgrounds appropriately?
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
gutee
Posts: 19
Joined: Wed Jan 09, 2019 9:12 am

Re: How to draw a rectangle in a spreadsheet

Post by gutee »

the hierarchical string list may be complex in my data, it should be more clear to show in the nested rectangles. but i still not find how to control shapes with the code in spreadsheet Macro.
OpenOffice.org.3.3.0
gutee
Posts: 19
Joined: Wed Jan 09, 2019 9:12 am

Re: How to draw a rectangle in a spreadsheet

Post by gutee »

I found a simple solution to draw into the spreadsheet :

Code: Select all

Sub test ()
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x = 1000
aPoint.y = 1000
aSize.Width = 10000
aSize.Height = 10000
Dim oRectangleShape As Object
Dim oDocument As Object
Dim oPage As Object

oDocument = ThisComponent
oPage = oDocument.drawPages(3)

oRectangleShape = oDocument.createInstance("com.sun.star.drawing.RectangleShape")
oRectangleShape.Size = aSize
oRectangleShape.Position = aPoint
oRectangleShape.FillColor = RGB(255,110,110)
oPage.add(oRectangleShape)
Dim oEllipseShape As Object
oEllipseShape = oDocument.createInstance("com.sun.star.drawing.EllipseShape")
oEllipseShape.Position = aPoint
oEllipseShape.Size = aSize
oEllipseShape.FillColor = RGB(100,255,110)
oPage.add(oEllipseShape)
Dim oTextShape As Object
oTextShape = oDocument.createInstance("com.sun.star.drawing.TextShape")
aPoint.x = 11000
aPoint.y = 11000
oTextShape.Position = aPoint
oTextShape.Size=aSize
oPage.add(oTextShape)
oTextShape.String="Hello World"
End Sub
OpenOffice.org.3.3.0
Post Reply