Please send me the code for changing the background color of a cell with a solid lightgay. As soon as I evaluate this functionality works fine, we will go ahead and purchase the component.
Prakash Billa
Coach
This message was posted using Email2Forum by salman.sarfraz.
Well, the color (LightGray) your want to apply is not present on the Standard Color Palette, so you have to add it first into the palette before setting it as a fill color of the cell. Since MS Excel (Excel97-Excel2003) Color Palette has only 56 colors (0-55 indexed) on it, so if a color is not there, you will have to add the color to the palette replacing any existing color on a specified index position.
Here is a sample code for your need:
//Instantiating a Workbook object Workbook workbook = new Workbook(); // Add Light Gray color to the palette. workbook.ChangePalette(System.Drawing.Color.LightGray, 55); //Obtaining the first worksheet by passing its sheet index Worksheet worksheet = workbook.Worksheets[0]; //Now setting the foreground color of the "A1" cell to light gray. worksheet.Cells["A1"].Style.ForegroundColor = Color.LightGray; //Setting the background pattern of the "A1" cell to solid worksheet.Cells["A1"].Style.Pattern = BackgroundType.Solid; //Saving the Excel file workbook.Save("d:\\test\\fillcolors.xls",FileFormatType.Default);
Can we insert a new row inside a existing excel file which has already data?
Example.
I have a excel file with 300 rows already populated. I would like to insert a new row at row position (0). I want a new row to be inserted and and all the existing data should be moved down. Is this possible. Seems to be existing worsheet.cells.insertrow(0) is not working.