emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How can I export a table to HTML with header and footers
@ 2024-10-17 19:14 Dr. Volker Zell
  2024-10-18  3:05 ` Raghavendra Nyshadham
  0 siblings, 1 reply; 2+ messages in thread
From: Dr. Volker Zell @ 2024-10-17 19:14 UTC (permalink / raw)
  To: emacs-orgmode

... see subject


Result should be like the following to be used with the datatable framwork


<table id="example" class="cell-border hover compact" width="100%">

   <thead>
     <tr>
       <th>Name</th>
       <th>Position</th>
       <th>Office</th>
     </tr>
   </thead>

   <tbody>
     <tr>
       <td>Tiger Nixon</td>
       <td>System Architect</td>
       <td>Edinburgh</td>
     </tr>
     <tr>
       <td>Ashton Cox</td>
       <td>Technical Author</td>
       <td>San Francisco</td>
     </tr>
   </tbody>

   <thead>
     <tr>
       <th>Name</th>
       <th>Position</th>
       <th>Office</th>
     </tr>
   </thead>

</table>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How can I export a table to HTML with header and footers
  2024-10-17 19:14 How can I export a table to HTML with header and footers Dr. Volker Zell
@ 2024-10-18  3:05 ` Raghavendra Nyshadham
  0 siblings, 0 replies; 2+ messages in thread
From: Raghavendra Nyshadham @ 2024-10-18  3:05 UTC (permalink / raw)
  To: emacs-orgmode

On 2024-10-18 00:44 +05:30, Dr. Volker Zell wrote:

> Result should be like the following to be used with the datatable framwork
>
> <table id="example" class="cell-border hover compact" width="100%">
>    <thead>
>      <tr>
>        <th>Name</th>
>        <th>Position</th>
>        <th>Office</th>
>      </tr>
>    </thead>
>
>    <tbody>
>      <tr>
>        <td>Tiger Nixon</td>
>        <td>System Architect</td>
>        <td>Edinburgh</td>
>      </tr>
>      <tr>
>        <td>Ashton Cox</td>
>        <td>Technical Author</td>
>        <td>San Francisco</td>
>      </tr>
>    </tbody>
>
>    <thead>
>      <tr>
>        <th>Name</th>
>        <th>Position</th>
>        <th>Office</th>
>      </tr>
>    </thead>
> </table>

AFAIK, exporting tables with specific id attributes is not straightforward,
but you can abuse the class attribute by putting the id in it.  For example,
if you export a file with the following text (C-c C-e h h), the output may be
like what you want.

Cheers,
Raghavendra.

#+title: Org Tables to DataTables
#+html_doctype: html5
#+html_head: <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
#+html_head: <script src="https://cdn.datatables.net/2.1.8/js/dataTables.min.js"></script>
#+html_head: <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.min.css" />
#+html_head: <script>$(document).ready(function () {$('table.example').DataTable();});</script>
#+html_head: <script>$(document).ready(function () {$('table.another-example').DataTable({lengthMenu: [3, {label: 'All', value: -1}]});});</script>

This is an example table.

#+attr_html: :class example cell-border hover compact :width 100%
| Name        | Position         | Office        |
|-------------+------------------+---------------|
| Tiger Nixon | System Architect | Edinburgh     |
| Ashton Cox  | Technical Author | San Francisco |

------------------------------------------------------------

This is another example table.

#+attr_html: :class another-example display
| Author            | Title                   | Shelf |
|-------------------+-------------------------+-------|
| Capote, Truman    | In cold blood           | D3B   |
| Chandler, Raymond | The high window         | D3B   |
| Dai, Mamang       | The legends of Pensam   | D3B   |
| Desai, Kiran      | The inheritance of loss | D3B   |
| Farrell, J. G.    | The hill station        | C1B   |


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-18  3:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 19:14 How can I export a table to HTML with header and footers Dr. Volker Zell
2024-10-18  3:05 ` Raghavendra Nyshadham

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).