HTML and Excel export problem in NG

Hi all,

I have an export (dataset) what I convert into HTML like dataset.getValue(1,1) etc etc

This all works fine, but because I dont use bytes I use the plugins.file.writeTXTFile method, to write the HTML as text.

code…
var _fname = ‘filename.xls’;
var _file = plugins.file.convertToJSFile(_dir + ‘\’ + _fname);
var _mime = ‘application/vnd.ms-excel’;
var _mimetype = ‘application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’;
var _file = plugins.file.convertToJSFile( _fname);
if( _file ) {
var _filename = _file.getAbsoluteFile();
if( plugins.file.writeTXTFile(_file, _data, ‘utf-8’, _mimetype)) {
var _b = plugins.file.readFile( _file )
var _f = plugins.file.convertToJSFile( _file )
if(_f && _f.canRead()){

plugins.file.writeFile(_filename, _b, _mimetype );
scopes.synchronize.openExcelFile(_file)
}
}
}

2 problems:

  1. When using the XLS extension with vnd.ms-excel mimetype I get an corrupted file error and can choose open the file or not (when opening Excel
    When using XLSX with vnd.openxmlformats-officedocument.spreadsheetml.sheet this option gives me an corrupted file error with no continue options (when opening Excle)

  2. When use this code in Developer it opens Excel nicely. But running from the server it does nothing, doesnt even give me an error in log.

The nice part is that I have an excel export with almost the same code, doing just fine. The only difference is the HTML and plugins.file.writeTXTFile

Code for running excel
application.executeProgram(“rundll32”, “url.dll,FileProtocolHandler”, _file);

Can someone help me to fix these problems?

Thanks

Derk

Hi Derk,

  1. You are rather manually generating the contents of the file?
    Why not use the Excel Export Plugin
    Or the svyExcelUtils extension if you have more in-depth requirements

  2. Which client do you run? For web clients (classic and NG) this command will always execute server-side (and without error)
    Browsers never have access to call an executable. You can open the file as a download. Then you will get the default action of the browser, which may prompt you to save it or open it directly.

By-the-way, we recently posted a webinar about this topic. If you haven’t watched it, you can catch up here

Hi Sean,

Yes I have seen the webinar.

I manually create the contents.

Weird part is when I do not use HTML in Excel the file opens fine.
But when using the HTML is does not.

I run NG 8.1.x ( update will be there soon)

Hi Derk,

Can you attach the file that you have exported?
I suspect that you have generated a malformed file that excel will refuse to open.

By-the-way, JSDataSet has a nice method to convert to html, that might save you some steps: getAsHTML

Attaching the file gives me an error

The upload was rejected because the uploaded file was identified as a possible attack vector.

I will send you an email.