<!-- Don't forget to update status.xml too! -->
<release version="3.1.1-alpha1" date="2008-??-??">
- <action dev="POI-DEVELOPERS" type="add">45582 - Fix for workbook streams with extra bytes trailing the EOFRecord</action>
+ <action dev="POI-DEVELOPERS" type="add">45577 - Added implementations for Excel functions NOW and TODAY</action>
+ <action dev="POI-DEVELOPERS" type="fix">45582 - Fix for workbook streams with extra bytes trailing the EOFRecord</action>
<action dev="POI-DEVELOPERS" type="add">45537 - Include headers and footers (of slides and notes) in the extracted text from HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45472 - Fixed incorrect default row height in OpenOffice 2.3</action>
<action dev="POI-DEVELOPERS" type="fix">44692 - HSSFPicture.resize() stretched image when there was a text next to it</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1.1-alpha1" date="2008-??-??">
- <action dev="POI-DEVELOPERS" type="add">45582 - Fix for workbook streams with extra bytes trailing the EOFRecord</action>
+ <action dev="POI-DEVELOPERS" type="add">45577 - Added implementations for Excel functions NOW and TODAY</action>
+ <action dev="POI-DEVELOPERS" type="fix">45582 - Fix for workbook streams with extra bytes trailing the EOFRecord</action>
<action dev="POI-DEVELOPERS" type="add">45537 - Include headers and footers (of slides and notes) in the extracted text from HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45472 - Fixed incorrect default row height in OpenOffice 2.3</action>
<action dev="POI-DEVELOPERS" type="fix">44692 - HSSFPicture.resize() stretched image when there was a text next to it</action>
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 15, 2005
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+
+/**
+ * Implementation of Excel NOW() Function
*
+ * @author Frank Taffelt
*/
-package org.apache.poi.hssf.record.formula.functions;
+public final class Now implements Function {
-public class Now extends NotImplementedFunction {
+ public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+ if (evals.length > 0) {
+ return ErrorEval.VALUE_INVALID;
+ }
+ java.util.Date now = new java.util.Date(System.currentTimeMillis());
+ return new NumberEval(HSSFDateUtil.getExcelDate(now));
+ }
}
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 15, 2005
- *
- */
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
package org.apache.poi.hssf.record.formula.functions;
-public class Today extends NotImplementedFunction {
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+/**
+ * Implementation of Excel TODAY() Function<br/>
+ *
+ * @author Frank Taffelt
+ */
+public class Today implements Function {
+
+ public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+ if (evals.length > 0) {
+ return ErrorEval.VALUE_INVALID;
+ }
+
+ Calendar now = new GregorianCalendar();
+ now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE),0,0,0);
+ now.set(Calendar.MILLISECOND, 0);
+ return new NumberEval(HSSFDateUtil.getExcelDate(now.getTime()));
+ }
}
+
import org.apache.poi.hssf.record.formula.Ptg;
/**
- *
+ *
* High level representation of Conditional Formatting Rule.
* It allows to specify formula based conditions for the Conditional Formatting
* and the formatting settings such as font, border and pattern.
- *
+ *
* @author Dmitriy Kumshayev
*/
-
public final class HSSFConditionalFormattingRule
{
- private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS;
+ private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS;
private final CFRuleRecord cfRuleRecord;
private final HSSFWorkbook workbook;
{
return cfRuleRecord;
}
-
+
private HSSFFontFormatting getFontFormatting(boolean create)
{
FontFormatting fontFormatting = cfRuleRecord.getFontFormatting();
- if ( fontFormatting != null)
+ if ( fontFormatting != null)
{
cfRuleRecord.setFontFormatting(fontFormatting);
return new HSSFFontFormatting(cfRuleRecord);
return null;
}
}
-
+
/**
* @return - font formatting object if defined, <code>null</code> otherwise
*/
return getFontFormatting(false);
}
/**
- * create a new font formatting structure if it does not exist,
+ * create a new font formatting structure if it does not exist,
* otherwise just return existing object.
- * @return - font formatting object, never returns <code>null</code>.
+ * @return - font formatting object, never returns <code>null</code>.
*/
public HSSFFontFormatting createFontFormatting()
{
return getFontFormatting(true);
}
-
+
private HSSFBorderFormatting getBorderFormatting(boolean create)
{
BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting();
- if ( borderFormatting != null)
+ if ( borderFormatting != null)
{
cfRuleRecord.setBorderFormatting(borderFormatting);
return new HSSFBorderFormatting(cfRuleRecord);
return getBorderFormatting(false);
}
/**
- * create a new border formatting structure if it does not exist,
+ * create a new border formatting structure if it does not exist,
* otherwise just return existing object.
- * @return - border formatting object, never returns <code>null</code>.
+ * @return - border formatting object, never returns <code>null</code>.
*/
public HSSFBorderFormatting createBorderFormatting()
{
return getBorderFormatting(true);
}
-
+
private HSSFPatternFormatting getPatternFormatting(boolean create)
{
PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting();
- if ( patternFormatting != null)
+ if ( patternFormatting != null)
{
cfRuleRecord.setPatternFormatting(patternFormatting);
return new HSSFPatternFormatting(cfRuleRecord);
return null;
}
}
-
+
/**
* @return - pattern formatting object if defined, <code>null</code> otherwise
*/
return getPatternFormatting(false);
}
/**
- * create a new pattern formatting structure if it does not exist,
+ * create a new pattern formatting structure if it does not exist,
* otherwise just return existing object.
- * @return - pattern formatting object, never returns <code>null</code>.
+ * @return - pattern formatting object, never returns <code>null</code>.
*/
public HSSFPatternFormatting createPatternFormatting()
{
return getPatternFormatting(true);
}
-
+
+ /**
+ * @return - the conditiontype for the cfrule
+ */
+ public byte getConditionType() {
+ return cfRuleRecord.getConditionType();
+ }
+
+ /**
+ * @return - the comparisionoperatation for the cfrule
+ */
+ public byte getComparisonOperation() {
+ return cfRuleRecord.getComparisonOperation();
+ }
+
public String getFormula1()
{
return toFormulaString(cfRuleRecord.getParsedExpression1());