テーブル関係のライブラリなんて今やってることにぴったりじゃん。

TableKit

TableKit is a collection of HTML table enhancements using the Prototype framework.

超簡単にソートやリサイズ、その場編集が可能なテーブルを作成できるJavaScriptライブラリ「TableKit」。
次のようなExcel風テーブルが簡単に作れます。

ヘッダのthをクリックするとエラーになる

cell.up is not a function
[Break on this error] table = (table && table.tagName && table.tagName !== "TABLE") ? $(table) : ce...

tablekit.js(652行目)を若干変更

    649     _editCell : function(e) {
    650         e = TableKit.e(e);
    651         var cell = Event.findElement(e,'td');
    652         if (cell.tagName && cell.tagName == 'TD') {
    653             TableKit.Editable.editCell(null, cell);
    654         }
    655     },

tdの中身が空の場合エラーになる

v has no properties
[Break on this error] v = parseFloat(v.replace(/^.*?([-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d...

tablekit.js の404行目に判定を追加

    399 TableKit.Sortable.addSortType(
    400     new TableKit.Sortable.Type('number', {
    401         pattern : /^[-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?/,
    402         normal : function(v) {
    403             // This will grab the first thing that looks like a number from a string, so you can use it to order a column of various srings containing numbers.
    404             if (v) {
    405                 v = parseFloat(v.replace(/^.*?([-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?).*$/,"$1"));
    406             }
    407             return isNaN(v) ? 0 : v;
    408         }}),

sorttype指定しないとnumberで比較してるみたい