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.
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?
You are almost there, but not quite:
e.CurrentWorksheet.Rows[excelrow].Cells[excelcol].CellFormat.FormatString = MyMask;
Has been a while, but, I've another problem, the FormatString Property worked, but I've to double clic in each cell to apply the format. The problem it's only on Excel, in LibreOffice works fine.
Isn't a method like ApplyFormat?
Thanks
I'm afraid I don't understand what you mean. What cell are you double-clicking on? Why do you have to double-click on anything?
For some cells my CellFormat is "hh:mm-hh:mm-hh:mm-hh:mm" so after export should look like this 00:00-00:00-00:00-00:00. But I've to double clic on the cell(edit mode) to apply the format(it's applied after leave the cell). If I don't, only looks this way 0000000000000000.
I hope you understand what I mean.
Hi Marcelo,
I'm afraid I still don't understand. The thread you are posting on here is about exporting the WinGrid to Excel. Are you doing that? It sounds like maybe you are just writing an Excel Worksheet directly and apply a format to certain cells.
There is no reason I can think of why you should have to double-click anything to get the formatting to appear. Or... are you saying that you are opening up the Excel sheet and applying the formatting manually in Excel instead of in code?