| View previous topic :: View next topic |
| Author |
Message |
dvaradharajan Power User


Joined: 02 Sep 2004 Posts: 81 Location: Chennai, India
|
Posted: Wed May 25, 2005 5:15 am Post subject: Creating select boxes with input values in calc. |
|
|
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 |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Mon May 30, 2005 8:22 am Post subject: |
|
|
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 |
|
 |
dvaradharajan Power User


Joined: 02 Sep 2004 Posts: 81 Location: Chennai, India
|
Posted: Tue May 31, 2005 10:29 am Post subject: |
|
|
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 |
|
 |
|