Hi,
I have a ultraWingrid and I export the data from the grid to an Excel file using the UltraGridExcelExporter
Everything works find but I still have a little problem
In the ultraWingrid the header background is Blue and the font color is white
When I export the data to an excel file the name of the header is exported but the font color is white.
So we don't see the name of each column :(
So we think that the name of each column is not exported which is not the case. The problem is just that the font color is white. Is there a way we can change the font color before exporting the data or after or change the backgroud color of the header in the excel file.
Because the user that export the data always think that the name of each columnis not there.
You have to know that all the ultraWingrid and form in my application use a template for color so the application look the same in every form.
Thanks in advance and have a nice day
Yes, you can change the forecolor of the header text just for the export without affecting the grid. What you do is handle the BeginExport event of the UltraGridExcelExporter. This event passes you a Layout, which is a clone of the grid's DisplayLayout. Since it's a clone, you can make any changes you want to this layout and it will affect the Exported Excel file, but have no effect on the on-screen grid. So you could set e.Layout.Override.HeaderAppearance.ForeColor, for example. You may, depending on the original grid settings, also need to turn off themes by setting ThemedElementAlpha (on the same appearance) to Transparent.
Having said that, you really should not need to work around this issue. The exported Excel file should be exporting the background color of the header cells as well as the forecolor. So if that's not happening, then something else is wrong, and you might want to resolve that issue rather than work around it.
Thanks for your answers I appreciate
I try what you suggest but it doesn't work
I desactivate the template we use for the application color of the forms ,grids, controls etc.. and then your code that you suggest work when the template is not set
Soon as I put back the template for the application the code you suggest doesn't work
It is like the template have priority over everything
Or there is something that I have to set somewhere that I don't know.
I understand when you say that the background color should be exported to the excel file but it doesn't
What I don't understand is Why the fore color for the text is exported and why not the backcolor of the header
Do you have any idea?
Thanks in advance!
What exactly do you mean by "template?" Are you talking about Application Styling?
Application Styling does override any property settings you apply to the grid by default. So if that's what you mean, then that would explain why it's not working.
If that's the case, then the question is, why isn't the exporter picking up the BackColor that the grid is using. I'm afraid I have no explaination for that. Can you duplicate this in a small sample project and post it here so I can try it out?
Yes I mean appllication style.
We use a file as a template to load the style for the application
I send you the file that we use in attachment SteelBlue.zip
Thanks in advance
The colors and styles provided by an Application Style Library will override any run-time property settings by default.
So there's no way to programmatically turn these off.
What I recommend is that you create a new UltraWinGrid in code and set UseAppStyling on the grid to false. Then you can bind this grid to the same data source as your real grid. You can use grid.DisplayLayout.CopyFrom to copy the layout of your real grid into this new grid. You might also want to hook up the new grid to some of the same events are your real grid, like InitializeLayout and InitializeRow so that the new grid has the same layout. Then you can export the new grid to Excel.
Hi, Im having similar issue but in my case I have the Noire Style but I want to turn it off when I export to excel. I want to have normal Black Font with White Background. I have tried overriding layout cell appearance without success.
Any clue?
Thank you very much for your answer.
I try what you explain me and it work out :)
I appreciate your help and I want to tell you that you are doing a very good job for us all the programmers
I wish you a nice day!
Okay, mystery solved. The reason Excel isn't picking up the colors is that no colors are applied but this isl file. It's coloring the headers in the grid by using an image, and Excel doesn't support cells with background images.
Open up the isl file in AppStylist and go the Header->GridHeader->GridColumnHeader role. Here you can see what settings are applied to the column header. Notice that on the Background chunk, Solid i selected and the selected color is Transparent. Also notice that there's a Resource applied on the Resources chunk. The resource is supplying the image which provides the blue gradient background. This was probably done using an image so that the image can provide the 3d borders.
Anyway... Excel cannot pick up the image from the on-screen grid, so it just uses the color - which is transparent. There's no reason why the color on this role should be transparent, since the image is covering the entire background on the screen, anyway. So the easiest way to fix it is to simply select a solid blue color that matches the background image.