+table-to-excel

This commit is contained in:
Thomas von Dein
2017-08-02 12:34:40 +02:00
parent 7af34a7b20
commit dba9d57dae
2 changed files with 709 additions and 666 deletions

28
.emacs
View File

@@ -597,6 +597,9 @@
;; - added C command to magit to switch repo ;; - added C command to magit to switch repo
;; - add : trigger for ido-find-file to begin with tramp ;; - add : trigger for ido-find-file to begin with tramp
;; 20170802.01
;; - +table-to-excel
;; ** TODO ;; ** TODO
;; - check helpful https://github.com/wilfred/helpful ;; - check helpful https://github.com/wilfred/helpful
@@ -3452,7 +3455,24 @@ intended to be #'> to support reverse sorting."
(switch-to-buffer ebuf) (switch-to-buffer ebuf)
(delete-file efile))) (delete-file efile)))
;; FIXME: once there's an org solution to this, remove this code
;; format specific exporters ;; format specific exporters
(defun tvd-org-quote-csv-field (s)
"Quote every field."
(if (string-match "." s)
(concat "=\"" (mapconcat 'identity
(split-string s "\"") "\"\"") "\"")
s))
(defun table-to-excel ()
"export current org table to CSV format suitable for MS Excel."
(interactive)
;; quote everything, map temporarily 'org-quote-csv-field
;; to my version
(cl-letf (((symbol-function 'org-quote-csv-field)
#'tvd-org-quote-csv-field))
(tvd-export-org-table "csv")))
(defun table-to-csv () (defun table-to-csv ()
"export current org table to CSV format" "export current org table to CSV format"
(interactive) (interactive)
@@ -3484,6 +3504,7 @@ intended to be #'> to support reverse sorting."
;; exporter shortcuts ;; exporter shortcuts
(defalias 'ttc 'table-to-csv) (defalias 'ttc 'table-to-csv)
(defalias 'tte 'table-to-excel)
(defalias 'ttl 'table-to-latex) (defalias 'ttl 'table-to-latex)
(defalias 'tth 'table-to-html) (defalias 'tth 'table-to-html)
(defalias 'ttt 'table-to-csv-tab) (defalias 'ttt 'table-to-csv-tab)
@@ -3561,9 +3582,10 @@ intended to be #'> to support reverse sorting."
(local-set-key (kbd "C-c o") 'org-table-copy-col) (local-set-key (kbd "C-c o") 'org-table-copy-col)
(local-set-key (kbd "C-c t") 'tvd-copy-org-table-cell)))) (local-set-key (kbd "C-c t") 'tvd-copy-org-table-cell))))
(with-eval-after-load 'orgtbl ;; eval-after-load 'orgtbl doesn't work
(define-key orgtbl-mode-map (kbd "C-c o") 'org-table-copy-col) (add-hook 'orgtbl-mode-hook '(lambda ()
(define-key orgtbl-mode-map (kbd "C-c t") 'tvd-copy-org-table-cell)) (define-key orgtbl-mode-map (kbd "C-c o") 'org-table-copy-col)
(define-key orgtbl-mode-map (kbd "C-c t") 'tvd-copy-org-table-cell)))
;; integers, reals, positives, set via custom ;; integers, reals, positives, set via custom
(setq org-table-number-regexp "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$") (setq org-table-number-regexp "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")

1347
emacs.html

File diff suppressed because it is too large Load Diff