Kentico Document Importer

After working with Kentico for some time, I’ve slowly developed a few little tools to help migrate information from our old site to the new Kentico framework. 

One of the things that’s a little time consuming in Kentico is creating documents.  I’ve decided to use a custom document type for a particular type of content on our new site.  The data for this new document type is in a bunch of different tables in the old website and I needed a way to get all that information into the Kentico content tree, and fast.

So… I created a module to do this.  It’s kind of simple and doesn’t look too flash but it works (if you follow the rules).

It takes a spreadsheet, uploads it to a temp folder and then creates documents at the specified path in the tree.  If you need it, it’s yours to do with as you see fit.

BTW: No warranty provided on this of course.

Download

The code is pretty simple:

While dsImport.Read
  ListBox1.Items.Add(dsImport.Item(0).ToString)
  'add documents

  nodTemp = New CMS.TreeEngine.TreeNode("NAS.Card")
  nodTemp.NodeName = dsImport.Item("NodeName").ToString
  nodTemp.NodeAlias = dsImport.Item("NodeName").ToString

  For i = 0 To strCols.Length - 1
    nodTemp.SetValue(strCols(I), dsImport.Item(strCols(I)))
  Next

  nodTemp.DocumentCulture = "en-au"
  nodTemp.Insert(parent.NodeID)
End While

The form collects a few things like the document type to create and the name of the columns in the spreadsheet to map to fields in the kentico document.  Looking at this at the moment I have left the document type hard coded, but you could easily change this to be driven from the form.

Additionally you’ll see at line 9 I loop through an array, this is derived from a comma separated list of column names to get from the excel sheet.  Let me know if you use it, just out of interest.