FLEXCEL STUDIO FOR .NET
5 | Page
Remember that OnGetImageInformation will be called for every image in the xls file,
even if they are not real images. For example, a chart will be rendered as an image,
and so it will throw an OnGetImageInformation event. Also, if you have vertical text
and the VerticalTextAsImages property is true, then this event will also be called
when creating the images with the vertical text.
CSS files are other place where you might create extra files. The HTML standard allows embedding
the CSS files inside the generated HTML or to use an external stylesheet, and so does
FlexCelHtmlExport. If you decide to go for an external stylesheet, you need to tell FlexCelHtmlExport
where to place it, by providing a TCssInformation class or a CSS filename to the export methods,
that it can use to figure out where to save it.
Embeding the generated HTML inside your own pages
Other thing you that is different in generating HTML from other file formats, is that you might want to
get only a part of the html file and not all of it. For example, imagine you want to embed an xls file
inside your existing company page. You will not want the whole html file (since embedding <html>
tags inside other <html> tags is not valid HTML), but only the part between the <body> tags. And
you will want to have the <head> part of the file in a separated place, so you can merge it with the
<head> tags in your site.
With FlexCelHtmlExport, you can use the PartialExportAdd method and the TPartialExportState
class for this.
You start by creating a new TPartialExportState instance, where FlexCel will store all the information it
needs to create your files.
Then, you call FlexCelHtmlExport.PartialExportAdd() for each sheet or file you want to add to the
HTML file, using the same TPartialExportState instance as parameter.
Once you have added all the sheets and files you want, you can use the methods in
TPartialExportState to get the individual parts of the HTML file.
Creating a file using FlexCelAspViewer component
The FlexCelAspViewer component is a component for .NET 2.0 or newer, that allows an easy
integration of the xls file with your ASP.NET site. Internally it uses FlexCelHtmlExport, and as
explained in the section above, it uses the PartialExportAdd method and TPartialExportState
class to inject the different parts of the HTML file inside the ASP.NET file you are designing.
While normally really straightforward to use (just drop it and set its properties), there is one thing to
take in account, and this is images.
FlexCelAspViewer needs a way to feed the images back to the browser. While it can send the HTML
text back to the main stream when the browser requests an ASP.NET page, it has no way to send the
images to the browser, when the browser requests them after reading the HTML file. Remember the
browser will make many requests, the first for an aspx file, and then for the individual png/jpg/gif
files, as shown below: