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
50
Formatting Currency columns in Excel
posted

Hi,

I am using Infragistics Excel to Export my dataset into multiple worksheets. I am having few currency fields in the Dataset , which i want to format(Ex., 1,00,000)

At present its returning without any format. Please lemme know how to do formatting for those columns.

Attached herewith the code

protected void lnkExport_Click(object sender, EventArgs e)
    {
        DataSet dsData = null;
        string[] Sheets = { "Sheet1", "Sheet2" };

        dsData = //Returns a dataset
       
            if (dsData.Tables.Count > 1)
            {
                int i = 0;
                int j = 0;
                Workbook workbk = new Workbook();
                WebExcelExporter objExcelExporter = new WebExcelExporter();
                WebControl[] prm = new WebControl[dsData.Tables.Count];
                objExcelExporter.ExportMode = Infragistics.Web.UI.GridControls.ExportMode.Custom;
                objExcelExporter.DownloadName = "Archives";

                for (i = 0; i < dsData.Tables.Count; )
                {
                    workbk.Worksheets.Add(ArchiveSheets[i].ToString());
                    i++;
                }

                foreach (DataTable dt in dsData.Tables)
                {
                    WebDataGrid wdg = new WebDataGrid();
                    wdg.AutoGenerateColumns = true;
                    wdg.StyleSetName = "Caribbean";
                    wdg.DataSource = dt;
                    wdg.DataBind();
                    this.Controls.Add(wdg);
                    if (i > j + 1)
                    {
                        objExcelExporter.Export(wdg, workbk.Worksheets[j]);
                    }

                    else
                    {
                        objExcelExporter.ExportMode = Infragistics.Web.UI.GridControls.ExportMode.Download;
                        objExcelExporter.Export(wdg, workbk.Worksheets[j]);
                    }

                    //workbk.Worksheets.Add(HoldingsSheets[i].ToString());
                    //prm[i] = this.GetWebDataGrid(dsReportData.Tables[i],HoldingsSheets[0].ToString() );                          
                    j++;
                }

            }          
       
       }