OK.. I give up.. I can get a basic export working, but I'd like to add a few rows before the export to show Client Name, Job, Address, etc.. 2 hours now and I have nothing working! I've checked the on line examples and they are, to be nice, pathetic...
I assume this is handled on the _BeginExport Method.. Where from there. anything I try using the BeginExportEventAgrs parameter get me nothing...
Also, my formatting of Int columns in my grid is correct (comma where applicible), but these formats DO NOT come over to Excel. Do I have to reformat all my cells?
I like your stuff, but you frustrate the hell out of me..
Thanks...
Hello,
we are still using Infragistis 8.3.
I have following problems:
We want to change the datasource that is bound to an ultragrid. Simply replacing the DataTables in a DataSet that is the datasource of the grid doesnt work. It seem like the grid is caching definitions for DataTables when the same tablename is used again. renaming the datatable before adding it to the dataset and afterwards renaming it again solved this isssue.
But now i want to export this ultragrid with an ultraGridExcelExporter. There it seems that i have the same problem. e.Layout.Bands[0].Columns.Count in ultraGridExcelExporter1_BeginExport remains the same as when we exported the first dataset.
the layout of our datatable in the dataset that is bound to the ultragrid changes over time. I.e. we fill the datatable according to some settings the user makes. The resulting datatable gets its content from data that is being analyzed to those settings. In one case we may have 4 columns to show in another case it would be 10 columns to show. But neither column must be identical to the previous analyzation.
Hope you can give me some hints
Greetings
Wolfgang Roth
Very Cool
Thanks!
Hi,
mgnatowski said: OK.. I give up.. I can get a basic export working, but I'd like to add a few rows before the export to show Client Name, Job, Address, etc.. 2 hours now and I have nothing working! I've checked the on line examples and they are, to be nice, pathetic... I assume this is handled on the _BeginExport Method.. Where from there. anything I try using the BeginExportEventAgrs parameter get me nothing...
The BeginExport event (and almost all of the events of the UltraGridExcelExporter) gives you a CurrentRowIndex and CurrentColumnIndex, as well as the CurrentWorksheet.
So if you want to add a line or two at the top before the grid exports, there's nothing to it. What you do is use the CurrentWorksheet and set the values on the cells. So let's say I wanted to add a line to the top of my worksheet where the first three cells say "A", "B", and "C". I would do this:
private void ultraGridExcelExporter1_BeginExport(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs e) { e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].Value = "A"; e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex + 1].Value = "B"; e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex + 2].Value = "C"; e.CurrentRowIndex++; }
Notice that I increment the CurrentRowIndex. This way, the grid starts exporting on the next row. If you add two rows, just add 2 to the CurrentRowIndex.
mgnatowski said:Also, my formatting of Int columns in my grid is correct (comma where applicible), but these formats DO NOT come over to Excel. Do I have to reformat all my cells?
DotNet Formats and Excel formats are not the same. So the grid can't just take the Format property of your column and translate it into Excel for you. What you have to do is handle the InitializeColumn event. The event gives you the format applied to the grid column and you just set the format on the excel column (on the event args).
Depending on the format, you can often just do this:
private void ultraGridExcelExporter1_InitializeColumn(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.InitializeColumnEventArgs e) { e.ExcelFormatStr = e.FrameworkFormatStr; }