Ask Your Question
1

Base, report, text fields : variable height

asked 2017-10-29 17:10:18 +0200

Denis_R gravatar image

updated 2017-10-29 19:27:24 +0200

Hello,

Using Base and ReportBuilder, I want to insert a text field that contains comments. But the comment length is variable and I would like the field height to vary according to the text length.

How can I do that ?

Denis

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2017-10-29 19:46:03 +0200

Ratslinger gravatar image

updated 2017-12-13 07:23:46 +0200

Hello,

I don't see any way in doing what you want without possibly some extensive macro coding. None of the report writers I use appear to have this capability although there are some limited options.

In your case, only what will fit within the field will be in the result.

EDIT:

Had a moment to do more research. Turns out Jaspersoft Studio has this function already. It is a simple setting on the field - "Stretch with Overflow". Since I don't print much or have had any need for this function I never knew it was there.

Sample:

Not stretched: image description

With stretched: image description

Just one other note, you cannot use this if running an Embedded DB. Any other should work as you connect to DB via JDBC connector.

BTW - I believe Report Builder is much more than 10 yrs now but has seen little if any mods in some time.

Edit 12/12/2017:

@Denis_R Saw again your link to the other post. Have had that entire code (posted code is small portion - all code is quite imense & somewhat complex!) for a while now but decided to give it a whirl to take my mind off another large project.

Spent a few hours to get one field on one row to expand successfully. Here was the result using Report Builder:

image description

This report was run entirely from a macro. Here is the code used:

Sub SetHeaderAutofit2
    ocontroller = Thisdatabasedocument.currentController
    if not ocontroller.isconnected then ocontroller.connect
    oreportdoc = Thisdatabasedocument.reportdocuments.getbyname("Report1").open
    document   = oreportdoc.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dispatcher.executeDispatch(document, ".uno:EditDoc", "", 0, Array())
    oTexttable = oreportdoc.Texttables
    oreportdoc.GetCurrentController().Select(oTexttable)
    oName = oTexttable.getByName("Detail")
    oCell=oName.getCellByPosition(2,0)
    oText = oCell.Text
    oCurs = oText.createTextCursor()
    oCurs.gotoEND(True)
    oName.getRows().getByIndex(0).IsAutoHeight = True    
End Sub

What makes this so difficult is that you have to configure what & where to expand because you need to work with the output document in edit mode. This means working with a text table (similar to calc) and locate specific cells. The last six lines (before End Sub) were specific to the single field and would be what needs repetition. The rest of the lines were just to get there.

So the code you pointed to works with some slight modifications (it was written for AOO older version) but it is a bear to implement. In my opinion, Jaspersoft was much easier to get running than to use this method.

If this answers your question please click on the ✔ (upper left area of answer).

edit flag offensive delete link more

Comments

My DB is embedded in LibreOffice ... and I moved from Ms Access to OpenOffice when I found the Sun Report Builder, 10 years ago :)

Since then I have reports with a text field that is either too big or too small ! But I professionally used report builder with such a functionality, sure.

Waiting for another 10 years ? :D

Denis_R gravatar imageDenis_R ( 2017-10-30 09:20:52 +0200 )edit
0

answered 2017-10-29 21:11:02 +0200

Denis_R gravatar image

Hi,

Thanks for the answer. It's something I am waiting since 10 years with the 1st Sun Report Builder ... Strange that nobody has such a need.

I found something here but I don't know how to apply that in my report. I will search ...

Denis

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2017-10-29 17:10:18 +0200

Seen: 559 times

Last updated: Dec 13 '17