Hi all, I have two cuestions today:
1) How can I set text style to the exported cells with Infragistics.Excel?
For example, when we must write the headers with bold text...
2) How can I set background and foreground color to the exported cells?
I have tried the following: Workbook Wb = new Workbook(WorkbookPaletteMode.StandardPalette);Worksheet Ws = Wb.Add("WorksheetName"); //Adding new worksheet to the workbookfor (int r = 0; r < 5; r++) {for (int c = 0; c < 5; c++) {Ws.Rows[r].Cells[c].CellFormat.FillPattern = FillPatternStyle.Solid;Ws.Rows[r].Cells[c].CellFormat.FillPatternBackgroundColor = Color.White; //throws exceptionWs.Rows[r].Cells[c].CellFormat.FillPatternForegroundColor = Color.Black;}}---- > Exception: "Index was outside the bounds of the array." relative to Infragistics.Excel.WorkbookColorCollection ... ¿Any ideas? Thanks!Jacobo.
I have tried the following:
Workbook Wb = new Workbook(WorkbookPaletteMode.StandardPalette);
Worksheet Ws = Wb.Add("WorksheetName"); //Adding new worksheet to the workbook
for (int r = 0; r < 5; r++) {
for (int c = 0; c < 5; c++) {Ws.Rows[r].Cells[c].CellFormat.FillPattern = FillPatternStyle.Solid;Ws.Rows[r].Cells[c].CellFormat.FillPatternBackgroundColor = Color.White; //throws exceptionWs.Rows[r].Cells[c].CellFormat.FillPatternForegroundColor = Color.Black;}
for (int c = 0; c < 5; c++) {
Ws.Rows[r].Cells[c].CellFormat.FillPattern = FillPatternStyle.Solid;Ws.Rows[r].Cells[c].CellFormat.FillPatternBackgroundColor = Color.White; //throws exceptionWs.Rows[r].Cells[c].CellFormat.FillPatternForegroundColor = Color.Black;
Ws.Rows[r].Cells[c].CellFormat.FillPattern = FillPatternStyle.Solid;
Ws.Rows[r].Cells[c].CellFormat.FillPatternBackgroundColor = Color.White; //throws exception
Ws.Rows[r].Cells[c].CellFormat.FillPatternForegroundColor = Color.Black;
}
---- > Exception: "Index was outside the bounds of the array." relative to Infragistics.Excel.WorkbookColorCollection ... ¿Any ideas?
Thanks!
Jacobo.
JHH said:1) How can I set text style to the exported cells with Infragistics.Excel?
Ws.Rows[r].Cells[c].CellFormat.Font.Bold = ExcelDefaultableBoolean.True;
JHH said:2) How can I set background and foreground color to the exported cells?
I tried out your code and it works fine for me, I get no exception. What version of the assemblies are you using? Do you have the latest Hot Fix? Can you post the complete call stack of the error?
Hi Mike,
Mike Saltzman"]What version of the assemblies are you using?
I am using Infragistics2....v7.3
Runtime version: v2.0.50727
Version: 7.3.20073.38
Mike Saltzman"]Can you post the complete call stack of the error? Do you have the latest Hot Fix?
Index was outside the bounds of the array. Target: .Drawing.Color get_Item(Int32)Source: .Excel.v7.3Stack: at Infragistics.Excel.WorkbookColorCollection.get_Item(Int32 index) at Infragistics.Excel.WorksheetCellFormatData.get_FillPatternBackgroundColor() at Infragistics.Excel.WorksheetCellFormatProxy.set_FillPatternBackgroundColor(Color value) at X.FormatoCeldasExcel.Aplicar(Worksheet Ws) at X.CuadranteExcelExporter.aplicarFormatosDeCeldas(Worksheet Ws) at X.CuadranteExcelExporter.Exportar(String Calendario, FilterHelper Filtro, DateTime FechaReferencia, Dictionary`2 OpcionesExportacion) at X.Cuadrante_Export(ExportEventArgs ExportArgs)
Thanks.
The error appears to be within the exporter code, so it's not likely that this is caused by anything in your code. It's most likely a bug.
It looks like you are using the original release version. You probably jus need to get the latest Hot Fix and I expect that this issue is already fixed. You can download the hot fix here:
My Infragistics Keys and Downloads - Download Anything and Everything You Own
If that doesn't help, you should Submit an incident to Infragistics Developer Support an, if possible, include a small sample project demonstrating the error so they can check it out.
Ok, I will try tomorrow upgrading to the last release.
Thanks for all Mike.