• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4783: excel2topics errors & and one enhancement

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension ExcelImportExportPlugin Normal Closed   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

I think there is a couple of errors in the excel2topics script that should be corrected.

First line 100, it seems to override my settings so that new topics dont get the wanted names. I solved it by commenting out line 100 and then it works:

98: my $newtopic=$data{$config{"TOPICCOLUMN"}};
99:## SMELL: Make default topic name configurable
100: $newtopic = 'ExcelRow'.$ct++;

And later there's an if statement at line 163 that dont evaluate to true because there are spaces before and/or after the column name variable. It can be fixed by removing the spaces, or of course timtowdi....I tried putting two lines extra(85 and 86):

84: $colname{$col}=$cell->Value if($cell);
+85: $colname{$col} =~ s/^\s*//go;
+86: $colname{$col} =~ s/^\s*//go;

Tried sending mail to plugin author (TW) but got uknown user receipient. This plugin jused to work because I have done it before, but maybe the cpan modules for parsing excel or something has changed...I dunno.

-- TWiki:Main/LarsEik - 07 Oct 2007

Correct line 86: $colname{$col} =~ s/\s*$//go;

-- TWiki:Main.LarsEik - 29 Oct 2007

to get Import to also add new fields that are not in an existing topic, but are in a newer definition of the TWikiForm, and in the spreadsheet, apply the following patch..

diff -u Import.pm.orig Import.pm
--- Import.pm.orig      2007-10-23 09:55:58.000000000 -0700
+++ Import.pm   2007-11-03 02:59:00.000000000 -0700
@@ -60,6 +60,17 @@
   $config{NEWTOPICTEMPLATE}= $query->param('newtopictemplate') || $config{NEWTOPICTEMPLATE};
   $config{DEBUG}      = $TWiki::Plugins::ExcelImportExportPlugin::debug;
 
+    #use the current definition of the TWikiForm
+    my $formDef = new TWiki::Form( $session, $webName, $config{FORM} );
+    unless( $formDef ) {
+        throw TWiki::OopsException(
+            'attention',
+            def => 'no_form_def',
+            web => $session->{webName},
+            topic => $session->{topicName},
+            params => [ $webName, $config{FORM} ] );
+    }
+
 
   my $xlsfile = $TWiki::cfg{PubDir}."/$webName/$topic/$config{UPLOADFILE}";
   $xlsfile = TWiki::Sandbox::untaintUnchecked( $xlsfile );
@@ -155,14 +166,17 @@
          $changed=1;
        }
 
-
        my %field;
 ## SMELL: Only copies the entries that are in the topic template. Should
 ## SMELL: this be the topics listed in the form/map instead?
        # search through all fields and find the field with the name $colname
+       my $foundField;
        foreach my $field ($meta->find("FIELD")) {
+#        $log .= "....$field?\n";
          if ($$field{"title"} eq $colname) {
+        #$log .= $$field{"title"}." eq $colname ... ".$$field{"value"}." ne ".$data{$colname}."\n";
            if ($$field{"value"} ne $data{$colname} ) {
+          $log .= $$field{"value"}." ne ".$data{$colname}."\n";
              my $msg="      $webName/$newtopic: $colname: old value=".$$field{"value"}." new value=$data{$colname}";
              $config{DEBUG} && TWiki::Func::writeWarning($msg);
              $log.="$msg\n";
@@ -178,10 +192,26 @@
                        };
              $meta->putKeyed( "FIELD", $fld);
            }
+               $foundField = 1;
            last; # found the field
          }
        }
-      }
+       #if the field was not in the topic, see if it should
+       unless ($foundField) {
+         if (grep { $colname eq $_->{name} } @{$formDef->getFields()} ) {
+        $log .= "adding missing $colname\n";
+             my $fld = {
+                        name =>TWiki::Form::_cleanField($colname),
+                        title=>$colname,
+                        value=>$data{$colname},
+                       };
+             $meta->putKeyed( "FIELD", $fld);
+             $changed=1;
+         }
+       }
+
+
+  }
 
       if ($changed) {          # only save if something has changed
        my ( $oopsUrl, $loginName, $unlockTime ) = TWiki::Func::checkTopicEditLock( $webName, $newtopic );


committed fixes & feature. -- SvenDowideit - 29 Jul 2008

ItemTemplate
Summary excel2topics errors & and one enhancement
ReportedBy TWiki:Main.LarsEik
Codebase 4.1.2, 4.2.0
SVN Range TWiki-4.3.0, Sat, 06 Oct 2007, build 15172
AppliesTo Extension
Component ExcelImportExportPlugin
Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:17191 TWikirev:17192
TargetRelease n/a
ReleasedIn

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2008-07-29 - SvenDowideit
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback