2013-07-18 34 views

回答

2
  1. 標記區域。
  2. M-x替換字符串
  3. |
  4. Ç-Q TAB RET

如果你想調整它,使用replace-regex

+0

是的,這應該工作,但有沒有包含'orgtbl'命令來做到這一點?正如OP所問,類似於「C-c |」的反義詞。 – quazgar

+0

聰明的解決方案,謝謝! –

4

嘗試用於製表符分隔值的orgtbl-to-tsv。

還有用於逗號分隔值的orgtbl-to-csv。

例如:

* Some heading 

    #+name: foo 
    | a | b | c | 
    |---+---+---| 
    | 1 | 2 | 3 | 
    | 4 | 5 | 6 | 

    #+BEGIN_SRC elisp :var x=foo 
    (orgtbl-to-csv x nil) 
    #+END_SRC 

    #+RESULTS: 
    : 1,2,3 
    : 4,5,6 
+0

這不正是這個問題想要避免的嗎?首先鍵入'org-table-export',然後選擇'orgtbl-to-tsv'。 – quazgar

+0

謝謝,我在Emacs版本化的_GNU Emacs 24.3.1(i386-mingw-nt6.1)中似乎沒有這些功能。7601)_在2013年3月17日在MARVIN。有任何想法嗎? –

+0

@quazgar:編輯的答案有幫助嗎? – Nick

2

下面是使用該表導出爲標籤或逗號分隔值的步驟:

  1. 使用命令ORG-表出口。 M-x org-table-export
  2. 輸入要保存到的文件名(或爲同一個文件點擊輸入)。
  3. 選擇格式(這是您可以設置orgtbl-to-tsv或任何其他格式的位置)。

這些都是可以使用的格式:

  • orgtbl到CSV
  • orgtbl到通用
  • orgtbl到HTML
  • orgtbl到 - 乳膠
  • orgtbl到orgtbl
  • orgtbl到的texinfo
  • orgtbl到TSV
0

我需要這個太,只是寫了下面的基礎上組織表出口:

(defun org-table-transform-in-place() 
    "Just like `ORG-TABLE-EXPORT', but instead of exporting to a 
    file, replace table with data formatted according to user's 
    choice, where the format choices are the same as 
    org-table-export." 
    (interactive) 
    (unless (org-at-table-p) (user-error "No table at point")) 
    (org-table-align) 
    (let* ((format 
     (completing-read "Transform table function: " 
       '("orgtbl-to-tsv" "orgtbl-to-csv" "orgtbl-to-latex" 
       "orgtbl-to-html" "orgtbl-to-generic" 
       "orgtbl-to-texinfo" "orgtbl-to-orgtbl" 
       "orgtbl-to-unicode"))) 
    (curr-point (point))) 
    (if (string-match "\\([^ \t\r\n]+\\)\\(+.*\\)?" format) 
    (let ((transform (intern (match-string 1 format))) 
      (params (and (match-end 2) 
       (read (concat "(" (match-string 2 format) ")")))) 
      (table (org-table-to-lisp 
       (buffer-substring-no-properties 
       (org-table-begin) (org-table-end))))) 
     (unless (fboundp transform) 
     (user-error "No such transformation function %s" transform)) 
     (save-restriction 
     (with-output-to-string 
      (delete-region (org-table-begin) (org-table-end)) 
      (insert (funcall transform table params) "\n"))) 
     (goto-char curr-point) 
     (beginning-of-line) 
     (message "Tranformation done.")) 
     (user-error "Table export format invalid")))) 

(define-key org-mode-map (kbd "\C-x |") 'org-table-transform-in-place) 

這將會是巨大的,如果這引起了加入組織模式正確因爲我認爲很多人會使用它。

相關問題