I'm using appstylist in several apps, and exporting styled-grid data to Excel workbooks. The problem is that, although the heading line of my resulting spreadhseet has my nice appstylized turquoise font color, it does not have the nice dark-blue background. The result is a spreadsheet where the heading row is almost impossible to read. I'd either like to get that background into the worksheet, or change the type in the worksheets heading line to dark blue, which I tried (see below), but it had no effect. I don't want to change the appearance of the grid as I'm happy with it, but I either want to turn appstyling export to excel off, or have ALL of the styled features of the grid exported, instead of only one, the heading text color.
myWorkbook.Worksheets("Report").Rows(0).Cells(0).CellFormat.Font.Color = Color.DarkBlue
Thanks.
Hello Samuel,
I followed the steps you suggested and was unable to reproduce the behavior you are describing. Using AppStylist I have made a TestStyleSet, that sets the background and fore color of the grid’s header respectively to navy and light blue. The ‘Excel Export’ button exports the grid with the TestStyleSet style applied to excel.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
In case this sample project is not an accurate demonstration of what you are trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
I have tested your code, and it works. However, I am programming in VB, not C#, and have no idea how to implement:
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
I presume these have something to do with your code working, and mine not - but perhaps I'm wrong. I only know that mine isn't working. I will open your isl and compare in appstylist.
I tested my sample project using your style and indeed the blue gradient background color is not exported to excel. The reason for this is that the GridColumnHeader background color is set to blue and the blue gradient is set to the background image. As MSExcel does not support setting background image to a cell, there is no way for the UltraGridExcelExporter to export the background image as well. What you can do in this case is removing the background image and resetting column headers’ background color to a gradient background that is similar to the one from the image you are using.
You can find and remove the image that was set to you style in the Style Explorer of the AppStylist, under the tab Resources (see attached file). Then going to Roles /Base/Header/GridHeader and clicking on GridColumnHeader you will see the GridColumnHeader explorer (the one from the image that you have sent). You can change the background color from the leftmost panel.
Well, that wort of works (and also sort of prooves my point about how confusing the UX of appstyleist is). But, there's still an issue. When I start the project now, it indeed shows the proper header now. However, I almost immediately call an 'applet' as a 'showdialog', and as soon as I do, all the grids on the calling page change, revert back to the appearance from the preset - complete with image, and then I have the same problem - so I think I have a 'war' going on between the preset and the appstylist. How do they interact, and which takes precedence, and how to control this?
Looks like the applet that was called loaded another appstylist, which retroactively changed the grids on the calling application. I've resolved the problem by having them all load the same isl file. I did not know that loading a new file would retroactively restyle open windows on calling programs...