DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:xls2wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tips:xls2wiki [2010-02-10 10:14]
92.70.151.87
tips:xls2wiki [2014-01-02 16:01]
– removed 46.218.111.82
Line 1: Line 1:
-====== xls2wiki ====== 
-~~UP~~ 
  
-===== Abstract ===== 
- 
-This is a simple script that converts copied data from xls to DokuWiki's Table format. The weird UTF-8 code you see is a russian explanation. 
- 
-Just copy cells in Excel and paste it, then press 'convert' 
- 
-===== code ===== 
- 
-<code php> 
-<?php header("Content-type: text/html; charset=UTF-8"); ?> 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> 
-<head> 
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
- <script type="text/javascript" charset="utf-8"> 
- function selText() 
-   { 
-   document.getElementById("txt1").select() 
-   } 
- </script> 
- 
- <style type="text/css"> 
- body { 
- font: .8em "Trebuchet MS", Verdana, Arial, Sans-Serif; 
- text-align: center; 
- color: #333; 
- background-color: #fff; 
- margin-top: 0em; 
- } 
-  
- h1 { 
- font-size: 2em; 
- padding: 0; 
- margin: 0; 
- } 
- 
- h5 { 
- font-size: 1em; 
- color: #09c; 
- font-weight: bold; 
- } 
-  
- form { 
- background-color: #eee; 
- border: 1px solid #ccc; 
- margin-left: auto; 
- margin-right: auto; 
- padding: 1em; 
- } 
- 
-  
- a { 
- color: #09c; 
- text-decoration: none; 
- font-weight: bold; 
- } 
- 
-  
- </style> 
- 
-</head> 
- <? 
- $s = $_POST['s']; 
- $fromto = $_POST['fromto']; 
- 
- if ($fromto=="E2W"){ 
- $s = str_replace("\r\n", " |\n| ", $s); 
- $s = str_replace("\t", " | ", $s); 
- $s = str_replace(" |", "| . |", $s); 
- $s = str_replace(" |", "| . |", $s); 
- $s = str_replace(" |", "| . |", $s); 
- $s = str_replace(" |", "| . |", $s); 
- $s = "| ".$s; 
- $s = substr($s,0,-2); //get rid of last newline conversion 
- }else{ 
- $s = str_replace("^", "|", $s); 
- $s = str_replace("|\r\n|", "\r\n", $s); 
- $s = str_replace("\r\n ", "\r\n", $s); 
- $s = str_replace(" |", "|", $s); 
- $s = str_replace("| ", "|", $s); 
- $s = str_replace("|", "\t", $s); 
- $s = substr($s,1); // get rid of first | without /r/n 
- 
- } 
- 
- ?> 
-<body onload="selText()"> 
-<center> 
-<h5>WIKI2EXCEL converter</h5> 
-Copy and paste your Excel or Wiki table below and press [Convert!]<br/> 
-Скопируйте и вставьте таблицу из  Excel или Wiki и нажмите [Convert!] (конвертировать) 
- <form method=POST action=""> 
- <input type="radio" name="fromto" value="E2W" checked>Excel » Wiki<br> 
- <input type="radio" name="fromto" value="W2E">Wiki » Excel<br> 
- <INPUT TYPE=SUBMIT VALUE="Convert!"><br/>  
- <textarea id="txt1" name="s" wrap="off" cols=80 rows=50 style="width:800; height:450"><? echo $s; ?></textarea> 
- </form> 
-<span style="font-size:80%"> 
-<strong>Version 0.1 : </strong> 
-<ul> 
-<li>Headers from wiki2excel will not be converted properly</li> 
-<li>Links with alternative text (like <i>[[link|alt.text]] ) will not convert properly</li> 
-</ul> 
-</span> 
-</center> 
-</body></html> 
-</code> 
- 
- 
- 
- 
- 
- 
- 
-===== Comments Support Wiki header on first Line  ===== 
- 
-I have find this script helpfull\\ 
-I would like just to add this lines to put the first line like an header :\\ 
- 
-<code php> 
- //explode the source by line with the use of regular expressions 
- 
- $arrayS = preg_split ("/[\n,]+/", $s); 
- 
- $nb_lines = count ($arrayS)-1; 
- $s = $s . $nb_lignes; 
- $s = ""; // we clean the text 
- foreach ( $arrayS as $key => $lines ){ 
- if ($key == 0) { 
-          
-                        //we put the header here on the first line  
-                      $lines = str_replace("|", "^", $lines);  
- 
- }//end if 
- $s = $s . $lines .  "\n"; 
- }//end for 
-  
- $s = substr($s,0,-2); //get rid of last newline conversion 
- 
-</code> 
- 
-finaly the code with english / french / russian translation, \\ 
-empty cells stay empty (no " . "), first line become header  : 
- 
-<code php> 
- 
-<?php header("Content-type: text/html; charset=UTF-8"); ?> 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> 
-<head> 
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
- <script type="text/javascript" charset="utf-8"> 
- function selText() 
-   { 
-   document.getElementById("txt1").select() 
-   } 
- </script> 
-  
- <style type="text/css"> 
- body { 
- font: .8em "Trebuchet MS", Verdana, Arial, Sans-Serif; 
- text-align: center; 
- color: #333; 
- background-color: #fff; 
- margin-top: 0em; 
- } 
-  
- h1 { 
- font-size: 2em; 
- padding: 0; 
- margin: 0; 
- } 
-  
- h5 { 
- font-size: 1em; 
- color: #09c; 
- font-weight: bold; 
- } 
-  
- form { 
- background-color: #eee; 
- border: 1px solid #ccc; 
- margin-left: auto; 
- margin-right: auto; 
- padding: 1em; 
- } 
-  
-  
- a { 
- color: #09c; 
- text-decoration: none; 
- font-weight: bold; 
- } 
-  
-  
- </style> 
-  
-</head> 
- <? 
- $s = $_POST['s']; 
- $fromto = $_POST['fromto']; 
-  
- if ($fromto=="E2W"){ 
-  
- 
- $s = str_replace("\r\n", " |\n| ", $s); 
- $s = str_replace("\t", " | ", $s); 
- //$s = str_replace(" |", "| . |", $s); 
-  
- $s = "| ".$s; 
- $s = substr($s,0,-2); //get rid of last newline conversion 
-  
-  
- //explode the source by line 
- $arrayS = preg_split ("/[\n,]+/", $s); 
- $nb_lines = count ($arrayS)-1; 
- $s = $s . $nb_lignes; 
- $s = ""; 
- foreach ( $arrayS as $key => $lines ){ 
- if ($key == 0) { 
- $lines = str_replace("|", "^", $lines);  
- }//end if 
- $s = $s . $lines .  "\n"; 
- }//end for 
-  
- $s = substr($s,0,-2); //get rid of last newline conversion 
- }else{ 
- $s = str_replace("^", "|", $s); 
- $s = str_replace("|\r\n|", "\r\n", $s); 
- $s = str_replace("\r\n ", "\r\n", $s); 
- $s = str_replace(" |", "|", $s); 
- $s = str_replace("| ", "|", $s); 
- $s = str_replace("|", "\t", $s); 
- $s = substr($s,1); // get rid of first | without /r/n 
-  
- } 
-  
- ?> 
-<body onload="selText()"> 
-<center> 
-<h5>WIKI2EXCEL converter</h5> 
- 
-Copy and paste your Excel or Wiki table below and press [Convert!]<br/> 
-Copier et coller votre Table Excel ou Wiki dans le cadre ci-dessous et cliquez sur [Convert!]<br/> 
-Скопируйте и вставьте таблицу из  Excel или Wiki и нажмите [Convert!] (конвертировать) 
- <form method=POST action=""> 
- <input type="radio" name="fromto" value="E2W" checked>Excel » Wiki<br> 
- <input type="radio" name="fromto" value="W2E">Wiki » Excel<br> 
- <INPUT TYPE=SUBMIT VALUE="Convert!"><br/>  
- <textarea id="txt1" name="s" wrap="off" cols=50 rows=50 style="width:400; height:450"><? echo $s; ?></textarea> 
- </form> 
-<span style="font-size:80%"> 
-<strong>Version 0.1 : </strong> 
-<ul> 
-<li>Headers from wiki2excel will not be converted properly</li> 
-<li>Links with alternative text (like <i>[[link|alt.text]]</i> ) will not convert properly</li> 
-</ul> 
-</span> 
-</center> 
-</body></html> 
- 
-</code> 
- 
- 
- 
-===== Installation ===== 
- 
-:?: Please forgive such a n00b question, but how does one install this helpful Trick?  A small installation section would be extremely helpful.  ;-) 
- 
-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:iframe]] 
- 
-you can **not** try to include directly the code in a wiki page either : 
-something like : 
- 
-<code> 
-<php> 
-Put the code here//§ 
-</php> 
-</code> 
-Because the page use little javascript tricks. 
- 
----- 
- 
-===== 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? Thx in adv. 
- 
-Resp.: I've found a way creating a wikipage and adding {{url>\\servername\drive\dokuwiki\XLStoWIKI.php}} to it. Is this the best way? Now I have the page but after pasting the spreadsheet content and hitting convert nothing seems to happen. Pls help. 
- 
-===== Remarks ===== 
- 
-If you like this you probably love this HTML converter as well : [[http://diberri.dyndns.org/wikipedia/html2wiki/index.html]] 
- 
-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?? 
- 
-Grtz Theo 
tips/xls2wiki.txt · Last modified: 2020-05-20 22:20 by gero-gothe

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki