Return-Path: X-Original-To: apmail-poi-dev-archive@www.apache.org Delivered-To: apmail-poi-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AC8F5954C for ; Wed, 25 Apr 2012 09:34:28 +0000 (UTC) Received: (qmail 840 invoked by uid 500); 25 Apr 2012 09:34:28 -0000 Delivered-To: apmail-poi-dev-archive@poi.apache.org Received: (qmail 793 invoked by uid 500); 25 Apr 2012 09:34:28 -0000 Mailing-List: contact dev-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Developers List" Delivered-To: mailing list dev@poi.apache.org Received: (qmail 777 invoked by uid 99); 25 Apr 2012 09:34:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 09:34:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.210.50] (HELO mail-pz0-f50.google.com) (209.85.210.50) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 09:34:20 +0000 Received: by dakh32 with SMTP id h32so2091268dak.9 for ; Wed, 25 Apr 2012 02:33:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=9bCX2ybxdaJ1G/aQ7XtC5Bcw0oJ2olA/HXyNnB8RjYQ=; b=CvABW/rZfm0LTv1X7WiPiPbuUjlMbCNw39QC68LMe5IHalKTSCWWc8UHtARi29SLwz fBDbkpblN3ezWkFcf4sZR2vigOjl9bOG0ostAE8uhVt2NgHZfq+SSUf2vxWCMYEkOFqK LgovNNrKYGpFp4FVgokI7QBSujz4o5VDbAvqopxtpYbJGTmOsKmyU69Ifue+O32XgGzT 9ToB1NEnIddfMLHEOTYh61p5mNM+1EZNAfZgDiyvq/93Nip0ZSRTcZPvgo3ZJzC63EXP bBRGmAkpY5jN7JxXrk6Y8EEjfOoOzQsRh6k+6Ghy+tDTIaiknBGcnB2DKswTkz+HWDEh 3/AA== MIME-Version: 1.0 Received: by 10.68.216.167 with SMTP id or7mr6047877pbc.140.1335346439640; Wed, 25 Apr 2012 02:33:59 -0700 (PDT) Received: by 10.68.6.102 with HTTP; Wed, 25 Apr 2012 02:33:59 -0700 (PDT) In-Reply-To: <2268C575-27F2-490C-A3B2-4B2068665DEC@mail.ntua.gr> References: <2268C575-27F2-490C-A3B2-4B2068665DEC@mail.ntua.gr> Date: Wed, 25 Apr 2012 13:33:59 +0400 Message-ID: Subject: Re: Custom Excel Functions From: Yegor Kozlov To: POI Developers List Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQk8m+jto5/L4HGOr8f3GBGrTgYMyT+98D0DKDeSJ4AIlroin0dQEAEcXMHtgNFjCjNd6QWM The array of ValueEval args contains all arguments passed to the function. If in Excel you pass N arguments, e.g. FUNC(arg1, arg2, arg3, ...., argN) then on the POI side the function takes it as a array of ValueEvals : {ve1, ve2, ve3, ...veN} where ve1 - ven are instances of the ValueEval interface. MINVERSE takes one argument so your code will receive a 1-length array of ValueEvals. The concrete type of ValueEval depends on what you pass in Excel: range, array or reference. In you code you should check the actual type with instanceof: case 1: passing a 2D area, e.g. MINVERSE(A1:C5) if( args[0]instanceof TwoDEval){ TwoDEval area = (TwoDEval )arg; } case 2: passing a reference to a 2D area, e.g. MINVERSE(A2) where A2 is a reference to B2: C5 else if( args[0]instanceof RefEval){ ; } case 3: passing a array, e.g. MINVERSE({1,2,3;4,5,6;7,8,9}) Unfortunately arrays are not yet supported. This means that the syntax like will not work and POI will throw a exception. > And then, how do I output an area back to the Excel spreadsheet? What is the calculation result? If it is a number then return NumberEval. If it is a range then return AreaEval. If the result is a array then POI cannot handle it. Array evals are not yet supported. Yegor --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org For additional commands, e-mail: dev-help@poi.apache.org