Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Exporting manually set text to excel
posted

Hi, 

I want to export Y for 1 and N FOR 0.Currently I have set this in InitializeRow in webdatagrid as

protected void WebDataGrid1_InitializeRow(object sender, RowEventArgs e)
{
string maskingValue = e.Row.Items[12].Text;
string masking = "";
double cellValue = 0D;

if (maskingValue != null)
{
if (maskingValue.ToUpper().Trim() == "T/F")
{
//allow nulls for Y/N
if (e.Row.Items[13].Text == "0")
e.Row.Items[6].Text = "N";
else if (e.Row.Items[13].Text == "1")
e.Row.Items[6].Text = "Y";

if (e.Row.Items[14].Text == "0")
e.Row.Items[7].Text = "N";
else if (e.Row.Items[14].Text == "1")
e.Row.Items[7].Text = "Y";

if (e.Row.Items[15].Text == "0")
e.Row.Items[8].Text = "N";
else if (e.Row.Items[15].Text == "1")
e.Row.Items[8].Text = "Y";

if (e.Row.Items[16].Text == "0")
e.Row.Items[9].Text = "N";
else if (e.Row.Items[16].Text == "1")
e.Row.Items[9].Text = "Y";

if (e.Row.Items[17].Text == "0")
e.Row.Items[10].Text = "N";
else if (e.Row.Items[17].Text == "1")
e.Row.Items[10].Text = "Y";

}

}

Where Item[12] is hidden.

protected void cmdExportToExcel_Click(object sender, EventArgs e)
{
bindWebDataGrid1();

logutils.createLogEntry(1, "LOB Distribution Export for MI: " + currentMI.modelInstanceID, loggedInUserID);
Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook();
workbook.Worksheets.Add(currentMI.modelInstanceID.ToString().Substring(0, 31).Replace("-", ""));
Infragistics.Documents.Excel.IWorkbookFont normalFont = workbook.Styles.NormalStyle.StyleFormat.Font;
normalFont.Name = "Microsoft Sans Serif";
normalFont.Height = 8 * 20;

WebExcelExporter1.Export(workbook.Worksheets[0], 1, 0, WebDataGrid1);

}

But 1/0 are not getting exported as Y/N. I can still se 1/0 in excel sheet. How to achieve this?