Saving a table to an excel file

Hi Guys,
The following code throws the error shown:

table = event.source.parent.getComponent("Root Container.Alarms.AlarmTable") fpmi.db.exportExcel("mytestdata.xls", 1, table.data)
Error:
Traceback (innermost last):
File “”, line 5, in ?
AttributeError: ‘None’ object has no attribute ‘data’

The table definately has data in it.

qurban,
I think your first line is not getting the table. None in Jython is the null value.

In the Script Editor (where you already are), click on the chain link icon on the right .
This will allow you to browse to your table. You must select a property of the object (like Name) and click OK. The path to your table will be generated in code.

  1. Remove the .Name
  2. Add table = before it.

The rest of your code looks good.

Thanks nathan. That worked fine.
Can you do the same with a chart, meaning that put the values behind the selected series into an excel file.

I’m glad that worked. I would recommend using an Easy Chart, which has a builtin disk icon in the top right to save the data to an Excel spreadsheet.

The Easy Chart also has it’s own chart.[b]exportExcel/b function defined.

You could use the fpmi.db.exportExcel function as you suggest with any dataSet, including one on a Chart (I don’t think the Easy Chart exposes its dynamically generated dataSets). The Easy Chart’s exportExcel function is superior to that of fpmi.db in that it will separate all dataSets as different Excel document tabs.

Hi Nathan: I read through this post and understand I think how to use a button click to create an excel file. Is it possible to highlight rows, or an entire table, copy that to the clipboard, and paste that into excel? When I try that I get everything in one cell. TIA D. Lewis

Hmm, this should work. I just took a look at it, and it turns out that it only works for multiple cells when the table is setup with the following properties:

Selection Mode: Single Interval
Row Selection Allowed: true
Column Selection Allowed: true

I’ll see what I can do to make this work better for other modes in 3.1

Thanks,