Hello,
I've got a windows service that I'd like to have an excel spreadsheet produced in. In the client, this is done via the Grid view Exporter. However, in the windows service, there are obviously no forms, so in order to do it this way, I would have to instantiate the RadGridView element, set its properties programmatically, set the datasource, and hope that it will be able to export a nicely formatted spreadsheet. When trying this, I was unable to get the grid's columns and rows to populate. Here is how I currently set it up:
grdResults.BackColor = System.Drawing.Color.White; |
// |
// |
// |
grdResults.MasterGridViewTemplate.AddNewRowPosition = Telerik.WinControls.UI.PinnedRowPosition.Bottom; |
grdResults.MasterGridViewTemplate.AllowAddNewRow = false; |
grdResults.MasterGridViewTemplate.AllowColumnChooser = false; |
grdResults.MasterGridViewTemplate.AllowDeleteRow = false; |
grdResults.MasterGridViewTemplate.AllowEditRow = false; |
grdResults.MasterGridViewTemplate.AllowRowResize = false; |
grdResults.MasterGridViewTemplate.AutoGenerateColumns = true; |
grdResults.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; |
grdResults.MasterGridViewTemplate.EnableGrouping = false; |
grdResults.MasterGridViewTemplate.ShowFilteringRow = false; |
grdResults.MasterGridViewTemplate.ShowRowHeaderColumn = false; |
grdResults.MultiSelect = true; |
grdResults.Name = "grdResults"; |
grdResults.ReadOnly = true; |
grdResults.ShowGroupPanel = false; |
grdResults.Size = new System.Drawing.Size(684, 461); |
grdResults.TabIndex = 15; |
grdResults.TabStop = false; |
((Telerik.WinControls.UI.GridTableElement)(grdResults.GetChildAt(0))).AlternatingRowColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(255)))), ((int)(((byte)(222))))); |
((Telerik.WinControls.UI.GridTableElement)(grdResults.GetChildAt(0))).RowHeight = 18; |
grdResults.Size = new Size(1000, 700); |
grdResults.DataSource = objRecordList; |
After the datasource is set, there are still no rows or columns, even though this should produce 67 rows and four columns. Is there an easier way to produce the desired spreadsheet from my list of objects? Alternatively, is there something I can do to get the grid to behave better so I can leverage the build-in exporter?
Thanks!
Jeremy