HTML and Excel export problem in NG

Forum to discuss the new web client version of Servoy.

HTML and Excel export problem in NG

Postby derk.hulshof » Tue Jul 03, 2018 2:50 pm

Hi all,

I have an export (dataset) what I convert into HTML like <td>dataset.getValue(1,1) </td> 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
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands

Re: HTML and Excel export problem in NG

Postby sean » Tue Jul 03, 2018 5:49 pm

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
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: HTML and Excel export problem in NG

Postby derk.hulshof » Wed Jul 04, 2018 4:35 pm

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)
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands

Re: HTML and Excel export problem in NG

Postby sean » Thu Jul 05, 2018 1:59 pm

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
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: HTML and Excel export problem in NG

Postby derk.hulshof » Fri Jul 06, 2018 8:40 am

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.
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 14 guests

cron