Exporting Column Header Captions from Excel Web Component

M

Michael Loughry

In my company's product, we set the ColumnHeadings.Caption property for each
column to be the description of the data in that column ("Address", "ID",
"Name", etc.). We do this largely so that the headers are not sorted with
everything else when the user sorts the whole table, but also so that the
table looks nicer.

However, when the user clicks the "Export Spreadsheet to Microsoft Excel",
these headers are not exported along with the data.

So, my question is how to have these headers exported as well? If that is
not possible, how might we be able to lock the first row (with the headers)
such that it cannot be sorted, whereas the rest of the data can still be
sorted? (Row.Locked = true does not seem to work.)

Any help would be appreciated.
 
A

Alvin Bruney [Microsoft MVP]

You can customize what is exported but it may be to much effort. One
approach is to tie into the export event and use COM to adjust the output -
that's not a walk in the park though.

The other approach is to handle the sort event and impose your own
customized sorting to exclude the header row.

For examples on how to do this, you can either download the office web
component toolpack which is free or you can purchase the blackbook which has
a customized sorting example in there. Either way, the code isn't that
difficult.


--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top