Hi
actually what we are doing according to our client has business requirement that they want to see percentage value some times with two decimal value sometimes 3 sometimes and sometimes with n.
since infragistic has max/min decimal value 2 for percent format default. so that we are achieving this by column formatter, where we restrict the number to display as desired number of decimals while creating column and its working perfectly, but now we are trying to export excel data, the problem occurring that the percentage value while exporting coming as '2.33%' string and exporting on excel cell whose type is number due to that its exporting data on cell with error says string is stored in number cells.
for that solution what i am thinking the cells value which is going to export to convert into float and set that cells format to percent.
something like this...
cellExporting: function (sender, args) { var filteredColumn = $.grep(sender._columnsToExport, function (v) { return v.hidden == false && v.key == args.columnKey }); if (filteredColumn.length > 0) { var format = filteredColumn[0].format; if (format == 'currency') { args.xlRow.getCellFormat(args.columnIndex).formatString('$#,##0.00_);[Red]($#,##0.00)'); } if (typeof (args.cellValue) == "string" && args.cellValue.contains('%')) { args.cellValue=parseFloat(args.cellValue); args.xlRow.getCellFormat(args.columnIndex).formatString('0.00%'); } }},
but unfortunatly its not setting the parsed value to cellValue, How i can achieve this. or there any better solution we have.
looking for your response.
Thanks
can i get help on this please...
Hi,
Thank you for detailed description.
1) When exporting a column that uses a formatter then the exporter uses the same valure returned by the formatter function. IF you format it as string, then it Is expected to receive it as a string in the args.cellValue in the cellExporting event.
2) I do not see a way to display a number as percent with more than two signs after the decimal separator.
Considering 1) and 2) the approach you use may be the best option possible. However I can take a further look if you send me your formatter function so that I am sure how you modify it.
Hi Hristo
as you said the option which i am using looks best, but the problem is i am not able to set cell value at cellExporting. so another approach which i followed is
cellExported: function (e, args) { if (typeof (args.cellValue) == "string" && args.cellValue.endsWith('%')) { var xlRow = args.xlRow; xlRow.cells(args.columnIndex).value(parseFloat(args.cellValue)/100); args.xlRow.getCellFormat(args.columnIndex).formatString('0.00%'); } },
thats working perfectly but i have doubt like i am degrading the export to excel performance by setting to time cell value for that column cell.
it will be very helpful for me if you tell me how we can reset value while cell exporting which i am doing at cell exported like parsing by float and dividing by 100.
meanwhile i have another two question :)
1.
cellExporting: function (sender, args) { var filteredColumn = $.grep(sender._columnsToExport, function (v) { return v.hidden == false && v.key == args.columnKey }); if (filteredColumn.length > 0) { var format = filteredColumn[0].format; if (format == 'currency') { args.xlRow.getCellFormat(args.columnIndex).formatString('$#,##0.00_);[Red]($#,##0.00)'); } } },
if you see in above function for currency values i am setting excel format to currency which works great but our application is used in french locale also so how we can set euro symbols instead of dollars.
2.
suppose in a page i have two grid, how can i export data of two grids in same workbook different sheet. is it possible if yes how can i achieve this.
Hi Ptilwani,
Sorry for late response. I was working on exporting two grids in the same workbook. This is not supported out of the box and I was working on a custom solution, ut it may take more time. However this is considered a product idea and you can log it at our Product Idea Site at at http://ideas.infragistics.com.
Regarding your other question - you set a different locale just by replacing the currency symbol in the format string here:
args.xlRow.getCellFormat(args.columnIndex).formatString('$#,##0.00_);[Red]($#,##0.00)');
so for frecnh the following will work:
args.xlRow.getCellFormat(args.columnIndex).formatString('#,##0.00 [$' + '\u20AC' + '-40C]');
The bold part will convert to the EUR currency symbol.
is there any update
1) but the problem is i am not able to set cell value at cellExporting
This is a known issue that is already fixed and will be rolled out with the volume release of 15.2 which is scheduled for 25 September. I suggest that once this release is available to upgrade your application to 15.2.
I am currently working on your other questions and will respond when done.