Export to Excel without a table

  • 2
  • Idea
  • Updated 3 years ago
  • Implemented
I found myself wanting to create a blank hidden table today just to use the export to excel function.

Is there a way to create a button to export all the fields from a model using the same functionality as the table export? (just without the table)
Photo of Greg Huete

Greg Huete

  • 2,340 Points 2k badge 2x thumb
  • exporting

Posted 6 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 55,248 Points 50k badge 2x thumb
Official Response
Actually, yes, you can!

At the simplest possible level, you can just call the "exportData() method on any Skuid Model once you get a reference to it:

var model = skuid.model.getModel('LeadData');

and this will do what you're looking for.

However, the exportData method takes a LOT of possible optional parameters. We haven't exposed all these to our API yet, but here's some you can rely on that you might want to use:

fileName: the name of the file that will be generated
rows: an array of the particular data rows in the model that you want to export
fields: an array of the particular Model Fields that you want to have included in the export (as the Columns)
useAPINamesForHeaders: boolean. Defaults to false, but if true, the API Names for fields will be used as Column Headers instead of the Labels. Can be useful for doing imports/exports between systems.
additionalConditions: an array of JavaScript Condition objects to limit the data in your Model that actually gets exported. These conditions will be applied to rows, if rows is specified, or to model.data, if rows is not provided.

These can be used like this:

var model = skuid.model.getModel('LeadData');
fileName: 'MyFile',
additionalConditions: [
{ field: "IsConverted", value: false, operator: '=' }

See the docs for more information.