Bug 55036 - [PATCH] patch for missing function Dec2HEx
Summary: [PATCH] patch for missing function Dec2HEx
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.10-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2013-05-31 17:23 UTC by Cédric Walter
Modified: 2013-10-11 19:16 UTC (History)
0 users

new function DEc2Hex with testcases (7.22 KB, application/gzip)
2013-05-31 17:23 UTC, Cédric Walter
Tests Dec2Hex() as loaded from a test data spreadsheet (28.00 KB, application/vnd.ms-excel)
2013-06-02 21:27 UTC, Cédric Walter
DEC2HEX_2.patch + test loader from spreadsheet (3.96 KB, text/plain)
2013-06-02 21:28 UTC, Cédric Walter

Note You need to log in before you can comment on or make changes to this bug.
Description Cédric Walter 2013-05-31 17:23:24 UTC
Created attachment 30350 [details]
new function DEc2Hex with testcases

new function DEc2Hex with testcases
Comment 1 Yegor Kozlov 2013-06-02 15:15:55 UTC
Thanks for the patch, applied in r1488729

I had to revert FunctionMetadataReader.java because it contained a debug code specific for your local environment:

 	public static FunctionMetadataRegistry createRegistry() {
-		InputStream is = FunctionMetadataReader.class.getResourceAsStream(METADATA_FILE_NAME);
+        InputStream is = null;
+        try {
+            is = new FileInputStream("C:\\innoveo\\workspace\\apache-poi-complexwildcard\\poi\\src\\resources\\main\\org\\apache\\poi\\ss\\formula\\function\\functionMetadata.txt");
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        //FunctionMetadataReader.class.getResourceAsStream(METADATA_FILE_NAME);
 		if (is == null) {
 			throw new RuntimeException("resource '" + METADATA_FILE_NAME + "' not found");

Comment 2 Yegor Kozlov 2013-06-02 15:51:14 UTC
There is some work to do
Dec2Hex is a function from the Excel Analysis Toolpack . It needs to implement FreeRefFunction and be registered in org.apache.poi.ss.formula.atp.AnalysisToolPak. Otherwise the formula evaluator will not find it. 

What you need to do:

(1) Declare Dec2Hex as implementing FreeRefFunction . There is one method to implement and you need to simply delegate it to the existing implementation:

    public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
        if (args.length != 2) {
            return ErrorEval.VALUE_INVALID;
        return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);    

(2) register Dec2Hex  in AnalysisToolPack, see how other functions are registered and follow the pattern.

(3) Provide a test(s) that evaluate functions from a real excel file. Attach the modified test workbook to this bug report.

Comment 3 Cédric Walter 2013-06-02 21:27:05 UTC
Created attachment 30373 [details]
Tests Dec2Hex() as loaded from a test data spreadsheet
Comment 4 Cédric Walter 2013-06-02 21:28:55 UTC
Created attachment 30374 [details]
DEC2HEX_2.patch + test loader from spreadsheet

found also a bug while doing integration tests in excel (negative integer), now solved
Comment 5 Cédric Walter 2013-10-11 19:16:57 UTC
merged in 1531395