OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Creating select boxes with input values in calc.

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
dvaradharajan
Power User
Power User


Joined: 02 Sep 2004
Posts: 81
Location: Chennai, India

PostPosted: Wed May 25, 2005 5:15 am    Post subject: Creating select boxes with input values in calc. Reply with quote

Hi,
I want to create the select boxes with data from a query.Is there a way i can create select boxes in calc.

I tried two things
1. Using validity I created the select box but was not able to set the source.
2. I also tried to create select box using form controls dynamically thru macro, but in vain.

any clues on this.

Thanks,
Dinesh
_________________
There's always one more bug- Murphy's law
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Mon May 30, 2005 8:22 am    Post subject: Reply with quote

This should insert a validation list into cell A1 of sheet Sheet1 under OO 2.0 beta ...

Hope that helps,

ms777
Code:
Sub Main
oCell  = ThisComponent.sheets.getByName("Sheet1").getCellByPosition(0,0)

oValid = oCell.getPropertyValue("Validation")

'use these lines only if you want to insert a new validation (no validation already given in the calc sheet)
oValid.IgnoreBlankCells = true
oValid.Operator = 1
oValid.ShowList = 1
oValid.Type     = 6

'always use these lines
oValid.Formula1 = """Joe"";""Jane"""
oCell.setPropertyValue("Validation", oValid)

End Sub
Back to top
View user's profile Send private message
dvaradharajan
Power User
Power User


Joined: 02 Sep 2004
Posts: 81
Location: Chennai, India

PostPosted: Tue May 31, 2005 10:29 am    Post subject: Reply with quote

Thanks ms777. It works. I did the implementation in java..

Code:
 com.sun.star.beans.XPropertySet xValidPropSet;
        try {
            xValidPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime
                    .queryInterface(com.sun.star.beans.XPropertySet.class,
                            xPropSet.getPropertyValue("Validation"));

            xValidPropSet.setPropertyValue("Type",
                    com.sun.star.sheet.ValidationType.LIST);
            com.sun.star.sheet.XSheetCondition xCondition = (com.sun.star.sheet.XSheetCondition) UnoRuntime
                    .queryInterface(com.sun.star.sheet.XSheetCondition.class,
                            xValidPropSet);
            xCondition.setOperator(com.sun.star.sheet.ConditionOperator.EQUAL);
            xCondition.setFormula1("\"Joe\";\"Jane\"");
           xPropSet.setPropertyValue("Validation", xValidPropSet);
        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }

Thanks,
Dinesh
_________________
There's always one more bug- Murphy's law
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group