<changes>
<release version="3.5-beta7" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="add">47771 - Added method setFunction(boolean) for defined names</action>
<action dev="POI-DEVELOPERS" type="add">47768 - Implementation of Excel "Days360" and "Npv" functions</action>
<action dev="POI-DEVELOPERS" type="fix">47751 - Do not allow HSSF's cell text longer than 32,767 characters</action>
<action dev="POI-DEVELOPERS" type="add">47757 - Added an example demonstrating how to convert an XLSX workbook to CSV</action>
* @author Sergei Kozello (sergeikozello at mail.ru)
* @author Glen Stampoultzis (glens at apache.org)
* @version 1.0-pre
+ *
+ * Modified 8/31/09 by Petr Udalau - added method setFunction(boolean)
*/
public final class NameRecord extends StandardRecord {
public final static short sid = 0x0018;
public boolean isFunctionName() {
return (field_1_option_flag & Option.OPT_FUNCTION_NAME) != 0;
}
+
+ /**
+ * Indicates that the defined name refers to a user-defined function.
+ * This attribute is used when there is an add-in or other code project associated with the file.
+ *
+ * @param value <code>true</code> indicates the name refers to a function.
+ */
+ public void setFunction(boolean function){
+ if (function) {
+ field_1_option_flag |= Option.OPT_FUNCTION_NAME;
+ } else {
+ field_1_option_flag &= (~Option.OPT_FUNCTION_NAME);
+ }
+ }
/**
* @return <code>true</code> if name has a formula (named range or defined value)
_definedNameRec.setDescriptionText(comment);
}
+ /**
+ * Indicates that the defined name refers to a user-defined function.
+ * This attribute is used when there is an add-in or other code project associated with the file.
+ *
+ * @param value <code>true</code> indicates the name refers to a function.
+ */
+ public void setFunction(boolean value) {
+ _definedNameRec.setFunction(value);
+
+ }
+
}
* name.setRefersToFormula("IF(Loan_Amount*Interest_Rate>0,1,0)");
*
* </blockquote></pre>
+ *
+ * Modified 8/31/09 by Petr Udalau - added method setFunction(boolean)
*/
public interface Name {
* @param comment the user comment for this named range
*/
public void setComment(String comment);
+
+ /**
+ * Indicates that the defined name refers to a user-defined function.
+ * This attribute is used when there is an add-in or other code project associated with the file.
+ *
+ * @param value <code>true</code> indicates the name refers to a function.
+ */
+ void setFunction(boolean value);
}
}
}
+
+ public void testFunctionNames() {
+ Workbook wb = getTestDataProvider().createWorkbook();
+ Name n = wb.createName();
+ assertFalse(n.isFunctionName());
+
+ n.setFunction(false);
+ assertFalse(n.isFunctionName());
+
+ n.setFunction(true);
+ assertTrue(n.isFunctionName());
+
+ n.setFunction(false);
+ assertFalse(n.isFunctionName());
+ }
}
\ No newline at end of file