I am trying to get certain rows to format as a percent while the default formatting is currency. We are using Infragistics NetAdvantage 2006 Volume 2 CLR 2.0 and .Net 2.0. Below is the code I have tried (including a commented out attempt.
protected void UltraWebGridExcelExporter1_EndExport(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.EndExportEventArgs e){ for (int j = 1; j < 7; j++) e.CurrentWorksheet.Columns[j].CellFormat.FormatString = CurFormat;
//int rowCount = (e.CurrentWorksheet.Rows as ICollection<Infragistics.Excel.WorksheetRow>).Count; int rowCount = e.CurrentWorksheet.Rows[((ICollection<Infragistics.Excel.WorksheetRow>)e.CurrentWorksheet.Rows).Count - 1].Index + 1; string headerValue;
for (int j = 1; j < rowCount; j++) { headerValue = Convert.ToString( e.CurrentWorksheet.Rows[j].Cells[0].Value);
if (headerValue.Contains("%")) { for (int jj = 1; jj < 7; jj++) e.CurrentWorksheet.Rows[j].Cells[jj].CellFormat.FormatString = PerFormat; } }}
The error I last got is pasted below:
Error Message: Unable to cast object of type 'Infragistics.Excel.WorksheetRowCollection' to type 'System.Collections.Generic.ICollection`1[Infragistics.Excel.WorksheetRowCollection]'.
Any suggestions or help in finding out the solution would be greatly appreciated.
Hi MikeHas this issue been sorted yetHow to get the number of actual rows please?
Thanks
Ok. Thank you for the all the help. :)
No, and in fact, even with the current version, the Count does not give you the number of rows with data. As I said before, it returns the number of rows which have already been lazily created. So just accessing a new row will increase the count.
So then with my version there is no way to get a value for the number of rows that actually have data?
Sorry, I meant you can iterate all rows possible (which will lazily create all rows), by always looping from 0 to 65535.