diff --git a/Base64.js b/Base64.js index e854d43..f0bf584 100644 --- a/Base64.js +++ b/Base64.js @@ -5,7 +5,7 @@ * **/ -var Base64 = (function() { +(function() { // private property var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; @@ -32,12 +32,10 @@ var Base64 = (function() { return utftext; } - // public method for encoding - return { + Ext.define("Ext.ux.exporter.Base64", { + statics: { //This was the original line, which tries to use Firefox's built in Base64 encoder, but this kept throwing exceptions.... // encode : (typeof btoa == 'function') ? function(input) { return btoa(input); } : function (input) { - - encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; @@ -61,6 +59,6 @@ var Base64 = (function() { keyStr.charAt(enc3) + keyStr.charAt(enc4); } return output; - } - }; + }} + }); })(); \ No newline at end of file diff --git a/Button.js b/Button.js index 7c49568..b7eda12 100644 --- a/Button.js +++ b/Button.js @@ -10,78 +10,51 @@ * @cfg {Ext.Component} component The component the store is bound to * @cfg {Ext.data.Store} store The store to export (alternatively, pass a component with a store property) */ -Ext.ux.Exporter.Button = Ext.extend(Ext.Button, { - constructor: function(config) { - config = config || {}; - - Ext.applyIf(config, { - exportFunction: 'exportGrid', - disabled : true, - text : 'Download', - cls : 'download' - }); - - if (config.store == undefined && config.component != undefined) { - Ext.applyIf(config, { - store: config.component.store - }); - } else { +Ext.define("Ext.ux.exporter.Button", { + extend: "Ext.Button", + alias: "widget.exporterbutton", + constructor: function(config) { + config = config || {}; + Ext.applyIf(config, { - component: { - store: config.store - } + disabled : true, + text : 'Download', + cls : 'download', + href : "/" }); - } - - Ext.ux.Exporter.Button.superclass.constructor.call(this, config); - - if (this.store && Ext.isFunction(this.store.on)) { - var setLink = function() { - this.getEl().child('a', true).href = 'data:application/vnd.ms-excel;base64,' + Ext.ux.Exporter[config.exportFunction](this.component, null, config); - - this.enable(); - }; - - if (this.el) { - setLink.call(this); + + Ext.ux.exporter.Button.superclass.constructor.call(this, config); + + if (this.store || this.component) { + this.setComponent(this.store || this.component, config); } else { - this.on('render', setLink, this); + var self = this; + this.on("render", function() { // We wait for the combo to be rendered, so we can look up to grab the component containing it + self.setComponent(self.up("gridpanel") || self.up("treepanel"), config); + }); } - - this.store.on('load', setLink, this); - } - }, - - template: new Ext.Template( - '', - '', - "
{0}
"), + }, - onRender: function(ct, position){ - var btn, targs = [this.text || ' ', this.href, this.target || "_self"]; - if (position){ - btn = this.template.insertBefore(position, targs, true); - }else{ - btn = this.template.append(ct, targs, true); - } - var btnEl = btn.child("a:first"); - this.btnEl = btnEl; - btnEl.on('focus', this.onFocus, this); - btnEl.on('blur', this.onBlur, this); + setComponent: function(component, config) { + this.component = component; + this.store = !component.is ? component : component.getStore(); // only components or stores, if it doesn't respond to is method, it's a store + var setLink = function() { + this.el.query('a', true)[0].href = 'data:application/vnd.ms-excel;base64,' + Ext.ux.exporter.Exporter.exportAny(this.component, null, config); + this.enable(); + }; - this.initButtonEl(btn, btnEl); - Ext.ButtonToggleMgr.register(this); + this.store.on("load", setLink, this); }, onClick : function(e){ - if (e.button != 0) return; - - if (!this.disabled){ - this.fireEvent("click", this, e); - - if (this.handler) this.handler.call(this.scope || this, this, e); - } + if (e.button != 0) return; + + if (!this.disabled){ + this.fireEvent("click", this, e); + + if (this.handler) this.handler.call(this.scope || this, this, e); + } } }); -Ext.reg('exportbutton', Ext.ux.Exporter.Button); \ No newline at end of file +//Ext.reg('exportbutton', Ext.ux.exporter.Button); \ No newline at end of file diff --git a/ExcelFormatter/Cell.js b/ExcelFormatter/Cell.js deleted file mode 100644 index 3f147ad..0000000 --- a/ExcelFormatter/Cell.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @class Ext.ux.Exporter.ExcelFormatter.Cell - * @extends Object - * Represents a single cell in a worksheet - */ -Ext.ux.Exporter.ExcelFormatter.Cell = Ext.extend(Object, { - - constructor: function(config) { - Ext.applyIf(config, { - type: "String" - }); - - Ext.apply(this, config); - - Ext.ux.Exporter.ExcelFormatter.Cell.superclass.constructor.apply(this, arguments); - }, - - render: function() { - return this.tpl.apply(this); - }, - - tpl: new Ext.XTemplate( - '', - '', - '' - ) -}); \ No newline at end of file diff --git a/ExcelFormatter/ExcelFormatter.js b/ExcelFormatter/ExcelFormatter.js deleted file mode 100644 index 41c2623..0000000 --- a/ExcelFormatter/ExcelFormatter.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @class Ext.ux.Exporter.ExcelFormatter - * @extends Ext.ux.Exporter.Formatter - * Specialised Format class for outputting .xls files - */ -Ext.ux.Exporter.ExcelFormatter = Ext.extend(Ext.ux.Exporter.Formatter, { - - format: function(store, config) { - var workbook = new Ext.ux.Exporter.ExcelFormatter.Workbook(config); - workbook.addWorksheet(store, config || {}); - - return workbook.render(); - } -}); diff --git a/Exporter.js b/Exporter.js index c098812..728b975 100644 --- a/Exporter.js +++ b/Exporter.js @@ -3,47 +3,66 @@ * @author Ed Spencer (http://edspencer.net) * Class providing a common way of downloading data in .xls or .csv format */ -Ext.ux.Exporter = function() { - return { - /** - * Exports a grid, using the .xls formatter by default - * @param {Ext.grid.GridPanel} grid The grid to export from - * @param {Object} config Optional config settings for the formatter - */ - exportGrid: function(grid, formatter, config) { - config = config || {}; - formatter = formatter || new Ext.ux.Exporter.ExcelFormatter(); - - Ext.applyIf(config, { - title : grid.title, - columns: grid.getColumnModel().config - }); - - return Base64.encode(formatter.format(grid.store, config)); - }, - - exportStore: function(store, formatter, config) { - config = config || {}; - formatter = formatter || new Ext.ux.Exporter.ExcelFormatter(); - - Ext.applyIf(config, { - columns: config.store.fields.items - }); - - return Base64.encode(formatter.format(store, config)); - }, - - exportTree: function(tree, formatter, config) { - config = config || {}; - formatter = formatter || new Ext.ux.Exporter.ExcelFormatter(); - - var store = tree.store || config.store; - - Ext.applyIf(config, { - title: tree.title - }); - - return Base64.encode(formatter.format(store, config)); +Ext.define("Ext.ux.exporter.Exporter", { + uses: [ + "Ext.ux.exporter.Base64", + "Ext.ux.exporter.Button", + "Ext.ux.exporter.csvFormatter.CsvFormatter", + "Ext.ux.exporter.excelFormatter.ExcelFormatter" + ], + + statics: { + exportAny: function(component, formatter, config) { + var func = "export"; + if(!component.is) { + func = func + "Store"; + } else if(component.is("gridpanel")) { + func = func + "Grid"; + } else if (component.is("treepanel")) { + func = func + "Tree"; + } + return this[func](component, formatter, config); + }, + + /** + * Exports a grid, using the .xls formatter by default + * @param {Ext.grid.GridPanel} grid The grid to export from + * @param {Object} config Optional config settings for the formatter + */ + exportGrid: function(grid, formatter, config) { + config = config || {}; + formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter(); + + Ext.applyIf(config, { + title : grid.title, + columns: grid.columns + }); + + return Ext.ux.exporter.Base64.encode(formatter.format(grid.store, config)); + }, + + exportStore: function(store, formatter, config) { + config = config || {}; + formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter(); + + Ext.applyIf(config, { + columns: config.store.fields.items + }); + + return Ext.ux.exporter.Base64.encode(formatter.format(store, config)); + }, + + exportTree: function(tree, formatter, config) { + config = config || {}; + formatter = formatter || new Ext.ux.exporter.excelFormatter.ExcelFormatter(); + + var store = tree.store || config.store; + + Ext.applyIf(config, { + title: tree.title + }); + + return Ext.ux.exporter.Base64.encode(formatter.format(store, config)); + } } - }; -}(); \ No newline at end of file +}); \ No newline at end of file diff --git a/Formatter.js b/Formatter.js index 1be5855..996bfd7 100644 --- a/Formatter.js +++ b/Formatter.js @@ -3,17 +3,16 @@ * @author Ed Spencer (http://edspencer.net) * @cfg {Ext.data.Store} store The store to export */ -Ext.ux.Exporter.Formatter = function(config) { - config = config || {}; - - Ext.applyIf(config, { - - }); -}; +Ext.define("Ext.ux.exporter.Formatter", { + /** + * Performs the actual formatting. This must be overridden by a subclass + */ + format: Ext.emptyFn, + constructor: function(config) { + config = config || {}; -Ext.ux.Exporter.Formatter.prototype = { - /** - * Performs the actual formatting. This must be overridden by a subclass - */ - format: Ext.emptyFn -}; \ No newline at end of file + Ext.applyIf(config, { + + }); + } +}); \ No newline at end of file diff --git a/build b/build index be27471..9ad0d29 100644 --- a/build +++ b/build @@ -14,8 +14,8 @@ Button.js Formatter.js -ExcelFormatter/ExcelFormatter.js -ExcelFormatter/Workbook.js -ExcelFormatter/Worksheet.js -ExcelFormatter/Cell.js -ExcelFormatter/Style.js \ No newline at end of file +excelFormatter/ExcelFormatter.js +excelFormatter/Workbook.js +excelFormatter/Worksheet.js +excelFormatter/Cell.js +excelFormatter/Style.js \ No newline at end of file diff --git a/CSVFormatter/CSVFormatter.js b/csvFormatter/CsvFormatter.js similarity index 59% rename from CSVFormatter/CSVFormatter.js rename to csvFormatter/CsvFormatter.js index c51e7f0..a34c2f3 100644 --- a/CSVFormatter/CSVFormatter.js +++ b/csvFormatter/CsvFormatter.js @@ -3,6 +3,6 @@ * @extends Ext.ux.Exporter.Formatter * Specialised Format class for outputting .csv files */ -Ext.ux.Exporter.CSVFormatter = Ext.extend(Ext.ux.Exporter.Formatter, { - +Ext.define("Ext.ux.exporter.csvFormatter.CsvFormatter", { + extend: "Ext.ux.exporter.Formatter" }); \ No newline at end of file diff --git a/excelFormatter/Cell.js b/excelFormatter/Cell.js new file mode 100644 index 0000000..65143d9 --- /dev/null +++ b/excelFormatter/Cell.js @@ -0,0 +1,27 @@ +/** + * @class Ext.ux.Exporter.ExcelFormatter.Cell + * @extends Object + * Represents a single cell in a worksheet + */ + +Ext.define("Ext.ux.exporter.excelFormatter.Cell", { + constructor: function(config) { + Ext.applyIf(config, { + type: "String" + }); + + Ext.apply(this, config); + + Ext.ux.exporter.excelFormatter.Cell.superclass.constructor.apply(this, arguments); + }, + + render: function() { + return this.tpl.apply(this); + }, + + tpl: new Ext.XTemplate( + '', + '', + '' + ) +}); \ No newline at end of file diff --git a/excelFormatter/ExcelFormatter.js b/excelFormatter/ExcelFormatter.js new file mode 100644 index 0000000..4bff4dd --- /dev/null +++ b/excelFormatter/ExcelFormatter.js @@ -0,0 +1,21 @@ +/** + * @class Ext.ux.Exporter.ExcelFormatter + * @extends Ext.ux.Exporter.Formatter + * Specialised Format class for outputting .xls files + */ +Ext.define("Ext.ux.exporter.excelFormatter.ExcelFormatter", { + extend: "Ext.ux.exporter.Formatter", + uses: [ + "Ext.ux.exporter.excelFormatter.Cell", + "Ext.ux.exporter.excelFormatter.Style", + "Ext.ux.exporter.excelFormatter.Worksheet", + "Ext.ux.exporter.excelFormatter.Workbook" + ], + + format: function(store, config) { + var workbook = new Ext.ux.exporter.excelFormatter.Workbook(config); + workbook.addWorksheet(store, config || {}); + + return workbook.render(); + } +}); \ No newline at end of file diff --git a/ExcelFormatter/Style.js b/excelFormatter/Style.js similarity index 90% rename from ExcelFormatter/Style.js rename to excelFormatter/Style.js index 72b71b5..24b6dce 100644 --- a/ExcelFormatter/Style.js +++ b/excelFormatter/Style.js @@ -2,7 +2,7 @@ * @class Ext.ux.Exporter.ExcelFormatter.Style * @extends Object * Represents a style declaration for a Workbook (this is like defining CSS rules). Example: - * + * * new Ext.ux.Exporter.ExcelFormatter.Style({ * attributes: [ * { @@ -24,28 +24,27 @@ * } * ] * }) - * + * * @cfg {String} id The ID of this style (required) * @cfg {Array} attributes The attributes for this style * @cfg {String} parentStyle The (optional parentStyle ID) */ -Ext.ux.Exporter.ExcelFormatter.Style = Ext.extend(Object, { - +Ext.define("Ext.ux.exporter.excelFormatter.Style", { constructor: function(config) { config = config || {}; - + Ext.apply(this, config, { parentStyle: '', attributes : [] }); - - Ext.ux.Exporter.ExcelFormatter.Style.superclass.constructor.apply(this, arguments); - + + Ext.ux.exporter.excelFormatter.Style.superclass.constructor.apply(this, arguments); + if (this.id == undefined) throw new Error("An ID must be provided to Style"); - + this.preparePropertyStrings(); }, - + /** * Iterates over the attributes in this style, and any children they may have, creating property * strings on each suitable for use in the XTemplate @@ -54,30 +53,30 @@ Ext.ux.Exporter.ExcelFormatter.Style = Ext.extend(Object, { Ext.each(this.attributes, function(attr, index) { this.attributes[index].propertiesString = this.buildPropertyString(attr); this.attributes[index].children = attr.children || []; - + Ext.each(attr.children, function(child, childIndex) { this.attributes[index].children[childIndex].propertiesString = this.buildPropertyString(child); }, this); }, this); }, - + /** * Builds a concatenated property string for a given attribute, suitable for use in the XTemplate */ buildPropertyString: function(attribute) { var propertiesString = ""; - + Ext.each(attribute.properties || [], function(property) { - propertiesString += String.format('ss:{0}="{1}" ', property.name, property.value); + propertiesString += Ext.String.format('ss:{0}="{1}" ', property.name, property.value); }, this); - + return propertiesString; }, - + render: function() { return this.tpl.apply(this); }, - + tpl: new Ext.XTemplate( '', '', diff --git a/ExcelFormatter/Workbook.js b/excelFormatter/Workbook.js similarity index 94% rename from ExcelFormatter/Workbook.js rename to excelFormatter/Workbook.js index 98dc705..b7d08b7 100644 --- a/ExcelFormatter/Workbook.js +++ b/excelFormatter/Workbook.js @@ -3,11 +3,11 @@ * @extends Object * Represents an Excel workbook */ -Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { - +Ext.define("Ext.ux.exporter.excelFormatter.Workbook", { + constructor: function(config) { config = config || {}; - + Ext.apply(this, config, { /** * @property title @@ -15,79 +15,79 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { * The title of the workbook (defaults to "Workbook") */ title: "Workbook", - + /** * @property worksheets * @type Array * The array of worksheets inside this workbook */ worksheets: [], - + /** * @property compileWorksheets * @type Array * Array of all rendered Worksheets */ compiledWorksheets: [], - + /** * @property cellBorderColor * @type String * The colour of border to use for each Cell */ cellBorderColor: "#e4e4e4", - + /** * @property styles * @type Array * The array of Ext.ux.Exporter.ExcelFormatter.Style objects attached to this workbook */ styles: [], - + /** * @property compiledStyles * @type Array * Array of all rendered Ext.ux.Exporter.ExcelFormatter.Style objects for this workbook */ compiledStyles: [], - + /** * @property hasDefaultStyle * @type Boolean * True to add the default styling options to all cells (defaults to true) */ hasDefaultStyle: true, - + /** * @property hasStripeStyles * @type Boolean * True to add the striping styles (defaults to true) */ hasStripeStyles: true, - + windowHeight : 9000, - windowWidth : 50000, + windowWidth : 50000, protectStructure: false, protectWindows : false }); - + if (this.hasDefaultStyle) this.addDefaultStyle(); if (this.hasStripeStyles) this.addStripedStyles(); - + this.addTitleStyle(); this.addHeaderStyle(); }, - + render: function() { this.compileStyles(); this.joinedCompiledStyles = this.compiledStyles.join(""); - + this.compileWorksheets(); this.joinedWorksheets = this.compiledWorksheets.join(""); - + return this.tpl.apply(this); }, - + /** * Adds a worksheet to this workbook based on a store and optional config * @param {Ext.data.Store} store The store to initialize the worksheet with @@ -95,53 +95,53 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { * @return {Ext.ux.Exporter.ExcelFormatter.Worksheet} The worksheet */ addWorksheet: function(store, config) { - var worksheet = new Ext.ux.Exporter.ExcelFormatter.Worksheet(store, config); - + var worksheet = new Ext.ux.exporter.excelFormatter.Worksheet(store, config); + this.worksheets.push(worksheet); - + return worksheet; }, - + /** * Adds a new Ext.ux.Exporter.ExcelFormatter.Style to this Workbook * @param {Object} config The style config, passed to the Style constructor (required) */ addStyle: function(config) { - var style = new Ext.ux.Exporter.ExcelFormatter.Style(config || {}); - + var style = new Ext.ux.exporter.excelFormatter.Style(config || {}); + this.styles.push(style); - + return style; }, - + /** * Compiles each Style attached to this Workbook by rendering it * @return {Array} The compiled styles array */ compileStyles: function() { this.compiledStyles = []; - + Ext.each(this.styles, function(style) { this.compiledStyles.push(style.render()); }, this); - + return this.compiledStyles; }, - + /** * Compiles each Worksheet attached to this Workbook by rendering it * @return {Array} The compiled worksheets array */ compileWorksheets: function() { this.compiledWorksheets = []; - + Ext.each(this.worksheets, function(worksheet) { this.compiledWorksheets.push(worksheet.render()); }, this); - + return this.compiledWorksheets; }, - + tpl: new Ext.XTemplate( '', '', @@ -158,9 +158,9 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { '{joinedCompiledStyles}', '', '{joinedWorksheets}', - '' + '' ), - + /** * Adds the default Style to this workbook. This sets the default font face and size, as well as cell borders */ @@ -170,7 +170,7 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { {name: "Weight", value: "1"}, {name: "LineStyle", value: "Continuous"} ]; - + this.addStyle({ id: 'Default', attributes: [ @@ -213,7 +213,7 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { ] }); }, - + addTitleStyle: function() { this.addStyle({ id: "title", @@ -237,7 +237,7 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { ] }); }, - + addHeaderStyle: function() { this.addStyle({ id: "headercell", @@ -266,7 +266,7 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { ] }); }, - + /** * Adds the default striping styles to this workbook */ @@ -283,7 +283,7 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { } ] }); - + this.addStyle({ id: "odd", attributes: [ @@ -296,14 +296,14 @@ Ext.ux.Exporter.ExcelFormatter.Workbook = Ext.extend(Object, { } ] }); - + Ext.each(['even', 'odd'], function(parentStyle) { this.addChildNumberFormatStyle(parentStyle, parentStyle + 'date', "[ENG][$-409]dd\-mmm\-yyyy;@"); this.addChildNumberFormatStyle(parentStyle, parentStyle + 'int', "0"); this.addChildNumberFormatStyle(parentStyle, parentStyle + 'float', "0.00"); - }, this); + }, this); }, - + /** * Private convenience function to easily add a NumberFormat style for a given parentStyle * @param {String} parentStyle The ID of the parentStyle Style diff --git a/ExcelFormatter/Worksheet.js b/excelFormatter/Worksheet.js similarity index 74% rename from ExcelFormatter/Worksheet.js rename to excelFormatter/Worksheet.js index a6255f0..74b9bc7 100644 --- a/ExcelFormatter/Worksheet.js +++ b/excelFormatter/Worksheet.js @@ -4,34 +4,34 @@ * Represents an Excel worksheet * @cfg {Ext.data.Store} store The store to use (required) */ -Ext.ux.Exporter.ExcelFormatter.Worksheet = Ext.extend(Object, { +Ext.define("Ext.ux.exporter.excelFormatter.Worksheet", { constructor: function(store, config) { config = config || {}; - + this.store = store; - + Ext.applyIf(config, { hasTitle : true, hasHeadings: true, stripeRows : true, - + title : "Workbook", columns : store.fields == undefined ? {} : store.fields.items }); - + Ext.apply(this, config); - - Ext.ux.Exporter.ExcelFormatter.Worksheet.superclass.constructor.apply(this, arguments); + + Ext.ux.exporter.excelFormatter.Worksheet.superclass.constructor.apply(this, arguments); }, - + /** * @property dateFormatString * @type String * String used to format dates (defaults to "Y-m-d"). All other data types are left unmolested */ dateFormatString: "Y-m-d", - + worksheetTpl: new Ext.XTemplate( '', '', @@ -72,7 +72,7 @@ Ext.ux.Exporter.ExcelFormatter.Worksheet = Ext.extend(Object, { '', '' ), - + /** * Builds the Worksheet XML * @param {Ext.data.Store} store The store to build from @@ -87,84 +87,88 @@ Ext.ux.Exporter.ExcelFormatter.Worksheet = Ext.extend(Object, { title : this.title }); }, - + buildColumns: function() { var cols = []; - + Ext.each(this.columns, function(column) { cols.push(this.buildColumn()); }, this); - + return cols; }, - + buildColumn: function(width) { - return String.format('', width || 164); + return Ext.String.format('', width || 164); }, - + buildRows: function() { var rows = []; - + this.store.each(function(record, index) { rows.push(this.buildRow(record, index)); }, this); - + return rows; }, - + buildHeader: function() { var cells = []; - + Ext.each(this.columns, function(col) { var title; - - if (col.header != undefined) { - title = col.header; - } else { - //make columns taken from Record fields (e.g. with a col.name) human-readable - title = col.name.replace(/_/g, " "); - title = title.charAt(0).toUpperCase() + title.substr(1).toLowerCase(); + + if(col.dataIndex) { + if (col.text != undefined) { + title = col.text; + } else { + //make columns taken from Record fields (e.g. with a col.name) human-readable + title = col.name.replace(/_/g, " "); + title = title.charAt(0).toUpperCase() + title.substr(1).toLowerCase(); + } + + cells.push(Ext.String.format('{0}', title)); } - - cells.push(String.format('{0}', title)); }, this); - + return cells.join(""); }, - + buildRow: function(record, index) { var style, cells = []; if (this.stripeRows === true) style = index % 2 == 0 ? 'even' : 'odd'; - + Ext.each(this.columns, function(col) { var name = col.name || col.dataIndex; - - //if given a renderer via a ColumnModel, use it and ensure data type is set to String - if (Ext.isFunction(col.renderer)) { - var value = col.renderer(record.get(name), null, record), - type = "String"; - } else { - var value = record.get(name), - type = this.typeMappings[col.type || record.fields.item(name).type]; + + if(name) { + //if given a renderer via a ColumnModel, use it and ensure data type is set to String + if (Ext.isFunction(col.renderer)) { + var value = col.renderer(record.get(name), null, record), + type = "String"; + } else { + var value = record.get(name), + type = this.typeMappings[col.type || record.fields.get(name).type.type]; + } + + cells.push(this.buildCell(value, type, style).render()); } - - cells.push(this.buildCell(value, type, style).render()); }, this); - - return String.format("{0}", cells.join("")); + + return Ext.String.format("{0}", cells.join("")); }, - + buildCell: function(value, type, style) { if (type == "DateTime" && Ext.isFunction(value.format)) value = value.format(this.dateFormatString); - - return new Ext.ux.Exporter.ExcelFormatter.Cell({ + + return new Ext.ux.exporter.excelFormatter.Cell({ value: value, type : type, style: style }); }, - + /** * @property typeMappings * @type Object