Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Getting row count from a worksheet to do row formatting
posted

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.

 

 

 

 

 

 

 

 

 

Parents Reply Children
No Data