Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

ExcelPaste

Summary: Copy and paste spreadsheet tables (e.g., from Excel) into pages
Version:
Prerequisites: pmwiki-2.0.0
Status: Stable
Maintainer: Pm
Categories: Editing, Tables
Votes:

Questions answered by this recipe

  • Is it possible to paste spreadsheet (Excel) or table (Word) data into a page?

Description

The tabtable.zipΔ (or patched tabtable-2007-08-15.zipΔ) script converts spreadsheet data into simple PmWiki tables. (This script requires PmWiki 2.0.beta22 or later.) With this recipe installed, an author can simply

  1. open a spreadsheet application
  2. select the cells to be pasted and copy them to the clipboard
  3. edit a PmWiki page
  4. paste the clipboard contents into the page's text area
  5. press the "Excel" button Excel button that appears in the button bar at the top of the editing area

PmWiki will then convert the pasted data into a simple PmWiki table, ready for editing. Numeric cells are automatically right aligned, while other cells are left aligned.

Installation

To install this script, download and unpack the tabtable.zipΔ (or patched tabtable-2007-08-15.zipΔ) . The tabtable.php script should go in the cookbook/ directory, and the excel.gif file should go in pub/guiedit/. Then add the following line to a local configuration file (e.g., local/config.php) before the final "?>" tag:

    include_once('cookbook/tabtable.php');

Notes and Comments

Problem with Archive

tabtable.zip seems to be a corrupt or damaged archive. Is there somewhere else to get this?

fixed original tabtable.zipΔ and patched tabtable-2007-08-15.zipΔ file. -- (jtankers)

Great! Works also with tables out of Word. Very supportive to help the 'naïve' users overcome the fear of working with tables in PmWiki. Thanks Pm for this one. (DirkBlaas)

Excellent! This recipe, along with BibtexRef and PmWikiDraw, proves that text isn't the only thing you can share. [RickL]

Could you please add the line with the th css background in the cookbook ?

SDV($HTMLStylesFmt['tabtable'],'
table.tabtable { border-collapse: collapse; }
table.tabtable td { border:1px solid #cccccc; }
table.tabtable th { background : #cccccc; }
');

Isidor

Does this recipe work with linux/oppen-office? GC

Yes. Tested with SUSE10 Desktop and OpenOffice 2.02

Does this work on a Mac with Microsoft Office 2004?

Yes, worked fine with Excel 2004 for Macintosh and Safari browser. (April 25, 2006)

This plugin also works to copy and paste from Google Spreadsheets.

Good plugin, but just wanted to mention that with the Beeblebrox-Gila Skin the Button is placed slightly higher for some reason. Don't know if it is due to the skin or this plugin. (July 4, 2006)^

Can I manually enter tab stop characters in the edit window to use this recipe to quickly generate tables in the browser?

Yes, if you know which key yields tab stop characters in your browser.

Which key yields tab stop characters in the Microsoft Internet Explorer on an XP machine? I tried the tab key along with most modifer keys and combinations of them without luck. --Henning October 24, 2006, at 01:07 PM

Tab is reserved for web page navigation, however you can type tab in Notepad or other text editor and copy/paste. -- (jtankers) August 6, 2007

Patch: make first row a heading (RussFink) The following is a diff-style patch for making tabtable add the '!' to the first row of the tables, thus causing them to appear as heading rows. If you don't want that, you can always manually edit and remove them, but I think for general purposes you might want this. Note, Patrick, if you disagree, please augment this with a variable that lets you deselect the behavior from config.php. I'm not that good of a PHP hack. Here's the patch.

--- tabtable.php        2005-02-25 10:30:23.000000000 -0700
+++ tabtable-raf.php    2007-01-23 10:21:41.000000000 -0700
@@ -50,15 +50,17 @@
     while ($row && count(end($row))==0) { array_pop($row); $x = "\n".$x; }
     if ($row) {
       $y[] = "||class='tabtable'";
+      $_first = '!'; /* RAF * first pass use heading formats */
       while ($row) {
         $col = array_shift($row);
         $r = '||';
         for($i=0; $i<count($wid); $i++) {
           $m = preg_match('/^\\s*\\(?-?[\\d,]+\\.?\\d*\\)?\\s*$/', @$col[$i])
-               ? " %{$wid[$i]}s||" : "%-{$wid[$i]}s ||";
+               ? "$_first %{$wid[$i]}s||" : "$_first%-{$wid[$i]}s ||"; /* RAF */
           $r .= sprintf($m,@$col[$i]);
         }
         $y[] = $r;
+        $_first = ''; /* RAF */
       }
       $row = array(); $wid = array();
     }

Nice recipe, but first shot revealed a serious bug: when you already have tables on your page, it repeats them all over the resulting page. So if you convert with this recipe, you should do it in an empty page and then copy-paste it to your target. (June 2007)

Awesome! This can be a huge first step in integrating a table into a wiki page leaving only minor formatting changes. Works great for me. I do have a feature request: i would like for the recipe to have the ability to convert to the advanced table markup instead of the "||" markup. -- lordmundi August 01, 2007, at 07:38 AM

That would be a powerful feature. I do like the standard mark up also, as it favors editor accessibility over display format.

Patch: Special characters and concise output (jtankers) This patch tabtable-jt (or patched tabtable-2007-08-15.zipΔ) converts embedded line feeds and pipes, trims extra spaces and conditionally makes first row a heading.

Suggestion for improvement: Use advanced table markup

Let the recipe generate advance table markup instead. This, combined with the recipe Cookbook:TableEdit, allows one to easier edit the pasted table.

Contributors

  • Pm Original script
  • RussFink Patch to make first row a header
  • jtankers Patch for special characters, concise code and detect header row

See Also

  • Text2Tbl Provide a way to convert arbitrarily structured text to table markup and provide conversion of simple tables to advanced.

Sandbox

This recipe has been enabled on this page, so you can experiment with it below. Follow the directions given in the description above.

  • use preview to view your text after pasting, then click on cancel
Edit - History - Print - Recent Changes - Search
Page last modified on May 22, 2009, at 06:46 PM