Export Extensions

文件资料 •
在此文中

Export apps are used to export data in a custom format.

  • Define attribute @task as export.file
    // @task = export.file

  • Define the extension of the file to be exported.
    // @exportfiletype = xml

  • The text to be written to the export file is the return value of the exec function and must be a return.
    return "exported text".

  • When the script terminate and if the return text is not null and does not start with "@Cancel ", the user will be promped with a dialog to choose a file name where to export. 

Example

Export all the accounting with description and balance in a xml file.

// @id = ch.banana.apps.export
// @api = 1.0
// @pubdate = 2016-04-08
// @doctype = *.*
// @description = Export into a text file (.txt)
// @task = export.file
// @exportfiletype = txt
// @timeout = -1

function exec() {
var exportResult = '<accounts>';
    var tableAccounts = Banana.document.table('Accounts');
    if ( !tableAccounts) {
      return;
   }
   for (i=0;i<tableAccounts.rowCount;i++) {
        if (tableAccounts.row(i).value('Account')) {
            exportResult += '<account>';
            exportResult += '<accountnr>' + tableAccounts.row(i).value('Account') + '</accountnr>';
            exportResult += '<description>' + tableAccounts.row(i).value('Description') + '</description>';
            exportResult += '<balance>' + tableAccounts.row(i).value('Balance') + '</balance>';
            exportResult += '</account>';
        }
    }
    exportResult += '</accounts>';
    //return the string
    return exportResult;
}

 

请帮助我们完善必备文件

我们非常欢迎您发送宝贵的反馈意见

请告诉我们什么主题需要更好的解释或如何才能更好的对其诠释。

分享这篇文章: Twitter | Facebook | LinkedIn | Email