Using the 8.1 version of the WinGrid and the Excel Exporter, I am able to export my grid results to Excel, just fine. A header row is included and, in the resulting Excel worksheet, I can see the 'value' of the header cells in the formula window of Excel. However, the actual header 'cells' appear to be blank.
In a separate application without appstyling, the same code works and I can see the values in the actual cells. Any ideas why the cells appear empty?
Follow up.....okay, I feel a little silly but the font on the header row in the worksheet is 'white'; probably from the appstyling. Is there a way to override the font as I am exporting so that the entire worksheet uses a visible font?
Hi Jerry,
The exporting should be WYSIWYG. So the colors used in the exported excel worksheet should be the same as those in the grid. So the only way the headers should be white-on-white in Excel is if they are also white-on-white on the screen. Is that the case?
So the question here is.. why is the exported workbook picking the forecolor of the header, but not the BackColor. It's possible that the BackColor might be coming from some themed drawing, so Excel would not be able to do that. But this might also just be a bug. I recommend that you create a a small sample project demonstrating this and Submit an incident to Infragistics Developer Support.
In the mean time, you could probably work around the issue by handling the HeaderCellExported event and change the Format on the cells. You should be able to either change the ForeColor or BackColor of each header cell to make the text readable.
Okay, cool. I will try that. I also notice that the font name that results is something Segoui (i'd have to double-check) but the Excel dialog says that font is not installed on my system.
Thanks for the input, Mike.
jc
SegoeUI is an Office 2007 font, I think. The applicaiton style you are using is propbably using that font. If it's not installed on your system, then the controls will fall back to another font when they try to draw text. The fact that it's still being exported to Excel that way is a bit odd and may be considered a bug.
Hi Mike,
I've got the same problem. When the application starts it loads my main form. In that forms load event I load my customised style library:
Infragistics.Win.AppStyling.StyleManager.Load(
This style library gives UltraWindGrid a dark blue header with white text. This was configured using the AppStyleList for Windows Forms via the Create New Library\Start from Template (Template_Cherry). A blue/grey colour palette was used.
On my form with the UltraWinGrid (called UltraGridData) I have an UltraGridExcelExporter (called UltraGridExcelExporter). I have a toolbar button that will try to export the grid on its click event.
UltraGridExcelExporter.Export(UltraGridData,
The file is created however the headers are white background with white text.
I'm giving the work around a go but not having much luck. In the HeaderCellExported I've tried each of the following without success:
e.GridHeader.Appearance.BackColor = Color.DarkBlue
e.CurrentWorksheet.Rows(0).CellFormat.FillPatternBackgroundColor = Color.DarkBlue
e.GridHeader.Column.CellAppearance.BackColor = Color.DarkBlue
Could you let me know what I'm doing wrong?
Regards
Nathan
I've seen this behavior recently. The reason this occurs is because this ISL file uses an image for the grid header background, and the Excel exporter doesn't export background images.
One workaround I'd found was to modify the ISL file to also set a background color for the grid headers. At runtime in WinGrid, you'll still see the image used for the background, and in the exported Excel file, you'll see the background color instead. I prefer this approach over setting the header colors, since you can modify each ISL file with an appropriate header background color to come as close as possible to the background image that is in use.
I haven't tested this, but to adjust this in the HeaderCellExported event, I'd use the following:
e.CurrentWorksheet.Rows(e.CurrentRowIndex).Cells(e.CurrentColumnIndex).CellFormat.FillPatternBackgroundColor = Color.DarkBlue
Hi Vince,
Excellent stuff. I modified the ISL as recommended and it worked a treat. I must admit I wasn't looking forward to have to write the code for each form that exported to excel, so this is a great solution.
Many thanks,