tips:xls2wiki
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tips:xls2wiki [2014-01-02 16:01] – removed 46.218.111.82 | tips:xls2wiki [2017-10-20 08:26] – 91.201.23.195 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== xls2wiki ====== | ||
+ | |||
+ | ===== Abstract ===== | ||
+ | |||
+ | This is a simple script that converts copied data from xls to DokuWiki' | ||
+ | |||
+ | Just copy cells in Excel and paste it, then press ' | ||
+ | |||
+ | ===== code ===== | ||
+ | |||
+ | <code php xls2wiki.php> | ||
+ | <?php header(" | ||
+ | < | ||
+ | <html xmlns=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <script type=" | ||
+ | function selText() | ||
+ | { | ||
+ | document.getElementById(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <style type=" | ||
+ | body { | ||
+ | font: .8em " | ||
+ | text-align: | ||
+ | color: #333; | ||
+ | background-color: | ||
+ | margin-top: | ||
+ | } | ||
+ | |||
+ | h1 { | ||
+ | font-size: | ||
+ | padding: 0; | ||
+ | margin: 0; | ||
+ | } | ||
+ | |||
+ | h5 { | ||
+ | font-size: | ||
+ | color: #09c; | ||
+ | font-weight: | ||
+ | } | ||
+ | |||
+ | form { | ||
+ | background-color: | ||
+ | border: 1px solid #ccc; | ||
+ | margin-left: | ||
+ | margin-right: | ||
+ | padding: 1em; | ||
+ | } | ||
+ | |||
+ | |||
+ | a { | ||
+ | color: #09c; | ||
+ | text-decoration: | ||
+ | font-weight: | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | <? | ||
+ | $s = $_POST[' | ||
+ | $fromto = $_POST[' | ||
+ | |||
+ | if ($fromto==" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = "| ".$s; | ||
+ | $s = substr($s, | ||
+ | }else{ | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = substr($s, | ||
+ | |||
+ | } | ||
+ | |||
+ | ?> | ||
+ | <body onload=" | ||
+ | < | ||
+ | < | ||
+ | Copy and paste your Excel or Wiki table below and press [Convert!]< | ||
+ | Скопируйте и вставьте таблицу из Excel или Wiki и нажмите [Convert!] (конвертировать) | ||
+ | <form method=POST action=""> | ||
+ | <input type=" | ||
+ | <input type=" | ||
+ | <INPUT TYPE=SUBMIT VALUE=" | ||
+ | < | ||
+ | </ | ||
+ | <span style=" | ||
+ | < | ||
+ | <ul> | ||
+ | < | ||
+ | < | ||
+ | </ul> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Comments Support Wiki header on first Line ===== | ||
+ | |||
+ | I have find this script helpful\\ | ||
+ | I would like just to add this lines to put the first line like an header:\\ | ||
+ | |||
+ | <code php> | ||
+ | // | ||
+ | |||
+ | $arrayS = preg_split ("/ | ||
+ | |||
+ | $nb_lines = count ($arrayS)-1; | ||
+ | $s = $s . $nb_lignes; | ||
+ | $s = ""; | ||
+ | foreach ( $arrayS as $key => $lines ){ | ||
+ | if ($key == 0) { | ||
+ | | ||
+ | //we put the header here on the first line | ||
+ | $lines = str_replace(" | ||
+ | |||
+ | }//end if | ||
+ | $s = $s . $lines . " | ||
+ | }//end for | ||
+ | |||
+ | $s = substr($s, | ||
+ | |||
+ | </ | ||
+ | |||
+ | > This converts cell contents like ", " (aka. ''< | ||
+ | |||
+ | Finally, the code with English / French / Russian translations, | ||
+ | empty cells stay empty (no " . "), first line become header: | ||
+ | |||
+ | <code php xls2wiki.php> | ||
+ | |||
+ | <?php header(" | ||
+ | < | ||
+ | <html xmlns=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <script type=" | ||
+ | function selText() | ||
+ | { | ||
+ | document.getElementById(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <style type=" | ||
+ | body { | ||
+ | font: .8em " | ||
+ | text-align: | ||
+ | color: #333; | ||
+ | background-color: | ||
+ | margin-top: | ||
+ | } | ||
+ | |||
+ | h1 { | ||
+ | font-size: | ||
+ | padding: 0; | ||
+ | margin: 0; | ||
+ | } | ||
+ | |||
+ | h5 { | ||
+ | font-size: | ||
+ | color: #09c; | ||
+ | font-weight: | ||
+ | } | ||
+ | |||
+ | form { | ||
+ | background-color: | ||
+ | border: 1px solid #ccc; | ||
+ | margin-left: | ||
+ | margin-right: | ||
+ | padding: 1em; | ||
+ | } | ||
+ | |||
+ | |||
+ | a { | ||
+ | color: #09c; | ||
+ | text-decoration: | ||
+ | font-weight: | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | <?php | ||
+ | $s = $_POST[' | ||
+ | $fromto = $_POST[' | ||
+ | |||
+ | if ($fromto==" | ||
+ | |||
+ | |||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | //$s = str_replace(" | ||
+ | |||
+ | $s = "| ".$s; | ||
+ | $s = substr($s, | ||
+ | |||
+ | |||
+ | // | ||
+ | $arrayS = preg_split ("/ | ||
+ | $nb_lines = count ($arrayS)-1; | ||
+ | $s = $s . $nb_lines; | ||
+ | $s = ""; | ||
+ | foreach ( $arrayS as $key => $lines ){ | ||
+ | if ($key == 0) { | ||
+ | $lines = str_replace(" | ||
+ | }//end if | ||
+ | $s = $s . $lines . " | ||
+ | }//end for | ||
+ | |||
+ | $s = substr($s, | ||
+ | }else{ | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = str_replace(" | ||
+ | $s = substr($s, | ||
+ | |||
+ | } | ||
+ | |||
+ | ?> | ||
+ | <body onload=" | ||
+ | < | ||
+ | < | ||
+ | |||
+ | Copy and paste your Excel or Wiki table below and press [Convert!]< | ||
+ | Copier et coller votre Table Excel ou Wiki dans le cadre ci-dessous et cliquez sur [Convert!]< | ||
+ | Скопируйте и вcтавьте таблицу из Excel или Wiki и нажмите [Convert!] (конвертировать) | ||
+ | <form method=POST action=""> | ||
+ | <input type=" | ||
+ | <input type=" | ||
+ | <INPUT TYPE=SUBMIT VALUE=" | ||
+ | < | ||
+ | </ | ||
+ | <span style=" | ||
+ | < | ||
+ | <ul> | ||
+ | < | ||
+ | < | ||
+ | </ul> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | There is a spell mistake here... | ||
+ | < | ||
+ | $nb_lines = count ($arrayS)-1; | ||
+ | $s = $s . $nb_lignes; | ||
+ | </ | ||
+ | |||
+ | nb_lignes should be **nb_lines**. | ||
+ | |||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | :?: Please forgive such a n00b question, but how does one install this helpful Trick? | ||
+ | |||
+ | My n00b answer: | ||
+ | |||
+ | use iframe.... | ||
+ | |||
+ | create a PHP page somewhere into your website DokuWiki root and put the code inside. | ||
+ | |||
+ | Use iframe to include this PHP page into a wiki page. | ||
+ | Look to this plugins if you hate HTML: [[plugin: | ||
+ | |||
+ | You can **not** try to include directly the code in a wiki page either: | ||
+ | something like: | ||
+ | |||
+ | < | ||
+ | <php> | ||
+ | Put the code here//§ | ||
+ | </ | ||
+ | </ | ||
+ | Because the page use little JavaScript tricks. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | More simple. Save xls2wiki.php to your dokuwiki\www\ folder and click this link: http:// | ||
+ | |||
+ | ---- | ||
+ | ===== Discussion ===== | ||
+ | I've installed iframe, but I'm kind of stuck how can I add the PHP file on the page I want to embed an excel spreadsheet. Can anyone help? Thanks in advance. | ||
+ | |||
+ | Resp.: I've found a way creating a wikipage and adding {{url> | ||
+ | |||
+ | ===== Remarks ===== | ||
+ | |||
+ | If you like this you probably love this HTML converter as well: [[http:// | ||
+ | |||
+ | Bad link! | ||
+ | |||
+ | ----- | ||
+ | |||
+ | Does not work for me, keep seeing " <? echo $s; ?> " in the input field, and convert does not do a thing, neither on IE nor on Firefox. | ||
+ | |||
+ | Perhaps I'm doing something wrong?? | ||
+ | |||
+ | -Theo | ||
+ | |||
+ | ----- | ||
+ | |||
+ | @theo: It's a " | ||
+ | |||
+ | -Steven | ||
+ | |||
+ | Changing the ini files worked for me - you also need to restart your Apache server before it will work. --- [[user> |
tips/xls2wiki.txt · Last modified: 2024-01-31 20:26 by 69.11.54.89