help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get text from LibreOffice Calc to Emacs Org-Mode


From: Gottfried
Subject: Re: get text from LibreOffice Calc to Emacs Org-Mode
Date: Sun, 30 Apr 2023 11:33:16 +0000

Hi,
thanks very much for your help.

1.
 1. Do you want to *import* a spreadsheet file (in ods, xls or xlsx
        format) import into a emacs org buffer

yes

I have no formulas in my spreadsheet file, only text.

2.
Do I have to install those two packages
(gnumerics the other is xlsx2csv)
in my GNU Guix Distro
(which I guess, you mean that),
or within emacs
(which I don’t guess, but I prefer to ask)

3.
Check the path, that these programs are correctly
installed before you execute my functions
 (or in case they are located
 differently adapt my functions accordingly).

Do you mean "check the path" in your functions?
(which I guess you mean that)

GNU Guix is different to a normal Linux distro,
but we will see.



Kind regards

Gottfried



Am 28.04.23 um 21:14 schrieb Uwe Brauer:
"G" == Gottfried  <gottfried@posteo.de> writes:

Hello


Hi,
(defun org-table-import-xlsx-to-csv-org ()
(interactive)
(let* ((source-file  (file-name-sans-extension (buffer-file-name 
(current-buffer))))
(xlsx-file (concat source-file ".xlsx"))
(csv-file (concat source-file ".csv"))
(org-odt-convert-processes '(("gnumeric" "~/.local/bin/xlsx2csv %i %o"))))
(org-odt-convert xlsx-file "csv")
(org-table-import csv-file  nil)))


(defun org-table-import-xls-to-csv-org ()
(interactive)
(let* ((source-file  (file-name-sans-extension (buffer-file-name 
(current-buffer))))
(xlsx-file (concat source-file ".xls"))
(csv-file (concat source-file ".csv")))
(org-odt-convert xlsx-file "csv")
(org-table-import csv-file  nil)))

(defun org-table-import-ods-to-csv-org ()
(interactive)
(let* ((source-file  (file-name-sans-extension (buffer-file-name 
(current-buffer))))
(xlsx-file (concat source-file ".ods"))
(csv-file (concat source-file ".csv")))
(org-odt-convert xlsx-file "csv")
(org-table-import csv-file  nil)))


I copied your suggestions into my init.el file

and tried to export a libreoffice calc file in xml format.


Now I am confused and maybe misunderstood you.

     1. Do you want to *import* a spreadsheet file (in ods, xls or xlsx
        format) import into a emacs org buffer

     2. Or do you want to *export* a org file to a spreadsheet file.

Both are possible, but from the thread I assume 1.

Before I am going to give a step by step instruction, two more comments

     1. The simplest strategy is, to convert the spreadsheet into csv and
        then into org in one go. However choosing this path means that
        you will not import spreadsheet formulas.

     2. Importing also spreadsheet formula is also possible but bit
        complicated, and most of the time you are faster by adding the
        formula manually in the org file yourself.

Now I should emphasise that you need two external programs, one is
gnumerics the other is xlsx2csv, a python based  converter that you can
install via pip. Check the path, that these programs are correctly
installed  before you execute my functions (or in case they are located
differently adapt my functions accordingly).

Now to the steps.

     1. Make a directory in which you copy the spreadsheet file (let us
        call this file table.ods).

     2. Now from within emacs, open the file table.org (that file does
        not exist but this way your create it). Please note it must have
        the same name as the spreadsheet file.

     3. Now since it is a ods file, run
        M-x org-table-import-ods-to-csv-org

     4. And the table should be generated, if not please report the error
        that then should be displayed

Regards




--


Attachment: OpenPGP_0x61FAF349C9FB7F94.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]