Hello, I have slightly improved the org-table-sum function. It calls directly calc-eval and yield the same result as vsum.
It can not handle better floating points. > | 171.00 | > | 4.07 | > | 4.44 | > | 2.61 | > | 12.21 | > | 6.69 | > | 19.72 | > | 23.09 | > | 6.23 | > | 15.28 | > | 250.00 | > | 250.00 | > | 250.00 | > | 78.85 | > |--------| > | | > #+TBLFM:@>$1=vsum(@1$1..@-1$1) diff --git a/lisp/org-table.el b/lisp/org-table.el index a3c49874c..ac237af2c 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -4728,6 +4728,18 @@ blank, and the content is appended to the field above." ((equal n 0) nil) (t n)))) + +(defun org-table-cell-no-prop (x) + "remove property from org-table-cell. If cell is empty output nil. X is a string - a cell from org-table +usage (org-table-cell-no-prop #(\"foo \" 0 2 (face default))) ==> foo +" + (interactive) + (let ( (res (replace-regexp-in-string "\s+" "" + (substring-no-properties x)))) + (when (not (equal res "")) + res) + )) + ;;;###autoload (defun org-table-sum (&optional beg end nlast) "Sum numbers in region of current table column. @@ -4769,9 +4781,9 @@ If NLAST is a number, only the NLAST fields will actually be summed." (t (setq items (reverse items)) (setcdr (nthcdr (1- nlast) items) nil) (nreverse items)))) - (numbers (delq nil (mapcar #'org-table--number-for-summing - items1))) - (res (apply '+ numbers)) + (numbers (delq nil (mapcar 'org-table-cell-no-prop items1 ))) + (res (string-to-number (calc-eval + (combine-and-quote-strings numbers "+")))) Best regards Jeremie Juste