You are almost there, but not quite:
e.CurrentWorksheet.Rows[excelrow].Cells[excelcol].CellFormat.FormatString = MyMask;
Thanks for your quick response. And sorry for my bad english.
I don't know if I'm doing well, but I've tried something like this:
int excelrow = e.CurrentRowIndex;
int excelcol = e.CurrentColumnIndex;
e.CurrentWorksheet.Rows[excelrow].Cells[excelcol].CellFormat = MyMask;
Which is the proper way to set the format in the cell?
Hi,
What you could do in a case like this is use the CellExported event. This event fires after the data has been written into the cell in the Excel Worksheet. The event args give you the grid row and column, so you can get the grid cell, and also the excel worksheet, row, and column index, so you can get the Excel cell. Once you have the cell, you can set the format on that cell to whatever you want.
Mike, I'm using NetAdvantage 2011.2 and I've differents Cell types (checkbox,textbox) in my ultragrid, and one of those have a mask as this:
I want to put the same value in excel but can't use InitializeColumn event due to the different cell types. Do you have an idea to solve this issue?
Hi Maciej,
The formats in DotNet are not always the same as the formats in Excel. They use a different set of format strings. So the grid can't automatically use the same formats when exporting to excel.
In order to handle this, the UltraGridExcelExporter has an event called InitializeColumn where you can get the format applied to the grid column and set the format to be applied to the Excel cells. Very often they are the same so you can just assign one to the other. But sometimes you might need to translate from a DotNet format into one Excel can handle.