DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44403>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44403

           Summary: MID Excel evaluates incorrectly
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P3
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


Overview Description
---------------------
The Excel function MID(text, start_num, num_chars) which has been implemented in
POI does not evaulate correctly.  It appears the function actually implements
MID(text, start_num, *end_num*) instead.

Steps to Reproduce
------------------
1/ Create a worksheet with the formula =MID("galactica", 3, 4) in a cell
2/ Notice in Excel, it evaulates to "lact" as expected
3/ Parse the file evaulating cell formulas 
(i.e. using 
HSSFFormulaEvaluator.CellValue cellValue = evaluator.evaluate(cell);
for example)
4/ Output will show "la" for the evaulated cell from 1/

Actual Results
--------------
As stated, actual results are "la"

Expected Results
----------------
As stated, expected results are "lact", given the Excel function signature for
MID is "MID(text, start_num, num_chars)" - Excel 2003

Build Date & Platform
---------------------
2008-02-07 on Windows XP

Additional Information
----------------------
In ./src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mid.java, I
believe the following change needs to be made:

line 93:

   retval = new StringEval(str.substring(startNum - 1, numChars));

should be replaced with:

  retval = new StringEval(str.substring(startNum - 1, (numChars + startNum - 
1)));

Much thanks as always

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to