Hi
I am exporting the WebDataGrid to the excel using WebExcelExporter. It is exporting nicely.
In the Excel sheet surpose in one column value has 1 and 0 but I want to replace 1 as "Yes" and 0 as "No" while opening the excel sheet.
How to do and solve this problem.
I am waiting for your replay and Thanks in Advance.
Hi Praveena,
This can be easily achieved by handling the CellExported event and set the value of this cell to what you need. In this way this should be exported in this way and saved.
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=Infragistics4.Web.v13.1~Infragistics.Web.UI.GridControls.WebExcelExporter~CellExported_EV.html
Something like this:
protected void WebExcelExporter1_CellExported(object sender, ExcelCellExportingEventArgs e)
{
if (e. CurrentColumnIndex ==1)
If (e. WorksheetCell.value == “1”)
e. WorksheetCell.value = “Yes”;
If (e. WorksheetCell.value == “0”)
e. WorksheetCell.value = “No”;
….
And here you can find similar approach:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0?page=WebGridExcelExporter_Transposing_Rows_and_Columns_using_WebGrid_Excel_Exporter.html
If you only need to do that while opening the file then you can simply use the Excel engine model and set to the cell the desired value:
If worksheet.Rows[2].Cells[2].Value ==”1”
worksheet.Rows[2].Cells[2].Value ==”Yes”;
You will find more info here:
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=ExcelEngine_Using_the_Infragistics_Excel_Engine.html
Please let me know if you have any furthered questions.
I am just checking if the latest reply helped you out and if you require any further assistance on the matter.
I have the same problem. But I want to check text or value property of particular column of each row and then set Y/N in excel. Below is the code. But I am getting N only in first row
and all the rows after row 1 have N only in cell[4] and all other cell like 0,1,2,3 are blank.
void WebExcelExporter1_CellExported(object sender, ExcelCellExportedEventArgs e) {int i = 2;foreach (GridRecord gr in WebDataGrid1.Rows){ if (gr.Items[6].Text == "N"){e.Worksheet.Rows[i].Cells[4].Value = "N";} i++; } }