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: Uwe Brauer
Subject: Re: get text from LibreOffice Calc to Emacs Org-Mode
Date: Fri, 28 Apr 2023 21:14:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>> "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



-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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