Sample: Producing fully styled Excel reports

Sample: Producing fully styled Excel reports

This handy example shows how you can extend the Excel production capabilities of Hub Edition applications. By using this simple recipe, you will be able to produce pretty-formatted XLS files that conform to the visual style of your application (by reusing its CSS in the Excel file).

In a nutshell, you must:

a) Produce a Web Screen, with the tabular content you want converted to Excel
In the attached eSpace file, this is screen NiceExcel. Open it to get a feel for the kind of content that can be successfully exported. It is worthy of note that this “producing” screen must be directly pointed at by an Entry point to be available as a URL;

b) Produce a Web Screen, with a submit Button/Link that will be used to request the download of the converted screen mentioned above
In the attached eSpace file, this is screen Main. If you open this screen you will see in the top-right corner an image with a link to the Screen Action DownloadExcel, which is out download trigger;

c) Produce the Screen Action linked by the submitter mentioned in b)
The Screen Action DownloadExcel shows what the contents of this action should be. These 5 simple steps are thoroughly explained as comments in the eSpace itself, please refer to the Screen Action for details.

Download the attached OML file and feel free to include and adapt it to your applications.

Any ideas on how to use this to create an excel file with multiple sheets?

I´m trying to look this example, but i´ve got the following error:

Missing Dependency
Could not find the 'EMS' Extension in this server. Application runtime errors might occur.

Can you tell me how to resolve this?
Hi Ivan,

Take a look into this post where you'll be able to see how you can replace the extension EMS by the extension BinaryData.

Tiago Simões

Has anyone tried this kind of solution with large amounts of data?
I need to get a report with more than 10.000 lines and this solution doesn't work.
It fails on the html transformation.
Any ideas on how to use this with large amounts of data?
My other other option is to write the report to a formated template stored as an oml resource. Any other ideas?

Hey guys,

Im trying to use this sample but when i try open/load the export excel file i get an error loading the css file.

Ive replaced the HttpGetExcel.Content with :
Replace(HttpGetExcel.Content,"<link href=""web.css"" type=""text/css"" rel=""stylesheet"">", "<style>" + HttpGetCss.Content + "</style>")

which is probably the error since it seems to use a relative link and not "http://localhost/NiceExcelReport/web.css"

- the http://localhost/NiceExcelReport/web.css is working properly

any suggestions about why this is happening?

bug: The replace wasnt working well on the sample.

Here goes my version of the sample Producing fully styled Excel reports with the "replace" fixed.
Hi Luis.

I was looking for a solution to produce an excel report and foud yours.

It works in fact, but I have only a little problem. When I open the resultant file, Microsoft Excel give's a warnig that the file is in a mismatch file format.
Is it possible to correct this mistake?

Thank you.
I get a style sheet mismatch error when I try uploading only certain versions of Excel.  The problem is that I use different versions for different purpose.  Any workarounds?


Hi Grahm,

Welcome to the OutSystems community forums. Could you be more specific? Do you have an eSpace that you're using, so we can look into it? And what kind of files are you having trouble with?


Paulo Tavares
Hey guys,

I was trying out this report and I get two errors, the first error already has been reported by Alexandre Alves, like he said Microsoft Excel gives a warning that the file is in a mismatch file format.

error 1

The other error is a little more critical, the Microsoft Excel fails to recognize the css file, só basically the download file don't have any style applied.

error 2

What should I do to make this work properly?

Thanks in advance.
Raquel Feitor
Hi Raquel,

take a look at this post here and see if it have what you need.

Hi Raquel,

Regarding the first warning message, it's really strange that the platform generates an excel file in a format different from the file extension. But if you save the file as .html that warning message disappears.

Regarding the second window (Problems During Load), you can solve this issue by specifing the complete URL to the css file:

Replace(HttpGetExcel.Content,"Theme.<yourStyle>.css", "http://<yourServer>.com/<youreSpace>/Theme.<yourStyle>.css").

If you inspect the generated code or debug it, we'll see that the css file has a quotation mark followed by a number. This number changes every time you publish your eSpace. So trying to use the Replace function as is will not work, since the string ("<link href=""web.css"" type=""text/css"" rel=""stylesheet"">") will not be found.

Since this solution does not replace the css file itself, but references it directly, it means that you need a internet connection for the style to be applied on your excel file.

If anyone knows a better solution, please share.


Complementing the reply from João:

I'm using 8.X version of OutSystems. In this version, the css is not generates with the name: "web.css". It's generated like this: Theme.NiceExcelReport.css?9999. The number after the question mark, like João said, is generated everytime you publish the application.

To solve this I used a Regex replace.
And in this newer version, there's a second css to add: _Basic.css.

I'm uploading an working example.

Victor Salvalagio
can anyone please provide a sample which can download excel with images and charts