Copying from C1FlexGrid ( ComponentOne )

Hi ya, I have a component grid that have multiple formats in each column. Some date, decimal ( F ) and some currency © with colors…I’m having troubles in copying this information to Excel. I’ve attempted the following…

//Copy the data in to spreadsheet row-by-row
for (int rowIndex = 0; rowIndex < grid.Rows.Count; rowIndex++) {
for (int colIndex = 0; colIndex < grid.Cols.Count; colIndex++) {
Object value = grid[rowIndex, colIndex];

if (value != null) {
string cellFormat = string.Empty;

// Get and set the format of excel cells
if (value.GetType() == typeof(DateTime))
cellFormat = grid.Cols[colIndex].Format;
else if (value.GetType() == typeof(Decimal)) {
cellFormat = grid.Cols[colIndex].Format;
if (cellFormat.Length > 0)
workbook.Worksheets[0].Cells[rowIndex, colIndex].Style.Custom = cellFormat;

//copy the value in to the Excel spread sheet.
workbook.Worksheets[0].Cells[rowIndex, colIndex].PutValue(value);

this doesn’t seem to copying colors and also decimals values are displaying as just ‘F’.

Could you please let me know what I’m doing wrong?


Could you post your generated excel file here, we will check your issue soon.

Thank you.