public static void CSVConverter(GridViewControl p_dataGridView)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "CSV (*.csv)|*.csv";
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                string fileName = saveFileDialog.FileName;
                StringBuilder stringBuilder = new StringBuilder();
                StreamWriter text = File.CreateText(fileName);
                foreach (DataGridViewColumn dataGridViewColumn in (BaseCollection)p_dataGridView.Columns)
                {
                    if (dataGridViewColumn.Visible)
                        stringBuilder.Append(dataGridViewColumn.HeaderText + ",");
                }
                text.WriteLine(stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1));
                stringBuilder.Length = 0;
                foreach (DataGridViewRow dataGridViewRow in (IEnumerable)p_dataGridView.Rows)
                {
                    foreach (DataGridViewColumn dataGridViewColumn in (BaseCollection)p_dataGridView.Columns)
                    {
                        if (dataGridViewColumn.Visible)
                            stringBuilder.Append((string)dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue + (object)",");
                    }
                    text.WriteLine(stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1));
                    stringBuilder.Length = 0;
                }
                text.Close();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void XMLConverter(GridViewControl p_dataGridView)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "XML (*.xml|*.xml";
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                string fileName = saveFileDialog.FileName;
                System.Data.DataTable dataTable = new System.Data.DataTable();
                if (p_dataGridView.DataSource.GetType().ToString() == "System.Data.DataSet")
                {
                    if ((DataSet)p_dataGridView.DataSource == null)
                        dataTable = ((DataSet)p_dataGridView.DataSource).Tables[p_dataGridView.DataMember];
                    else if (p_dataGridView.DataMember != null && p_dataGridView.DataMember != "")
                    {
                        string[] strArray = p_dataGridView.DataMember.ToString().Split('.');
                        if (strArray.Length > 0)
                        {
                            string index = strArray[strArray.Length - 1];
                            dataTable = ((DataSet)p_dataGridView.DataSource).Relations[index] == null ? ((DataSet)p_dataGridView.DataSource).Tables[index] : ((DataSet)p_dataGridView.DataSource).Relations[index].ChildTable;
                        }
                    }
                }
                else
                    dataTable = (System.Data.DataTable)p_dataGridView.DataSource;
                dataTable.WriteXml(fileName);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string ExcelConverterWithSetting(GridViewControl p_dataGridView, System.Data.DataTable _dtGridOrder, bool p_with_priview)
        {
            /*
            Microsoft.Office.Interop.Excel.Application application = (Microsoft.Office.Interop.Excel.Application)null;
            _Workbook workbook = (_Workbook)null;
            _Worksheet worksheet1 = (_Worksheet)null;
            string str1 = (string)null;
            System.Data.DataTable dataTable1 = (System.Data.DataTable)null;
            string str2 = "Not Assigned";
            try
            {
                _dtGridOrder.DefaultView.RowFilter = "COLUMN_VISIBLE='Y'";
                System.Data.DataTable dataTable2 = _dtGridOrder.DefaultView.ToTable();
                if (dataTable2.Rows.Count == 0)
                {
                    int num = (int)MessageBox.Show("Please Set Excel Export Setting First!!!");
                    return (string)null;
                }
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Excel(*.xlsx|*.xls";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {

                    str1 = saveFileDialog.FileName;
                    if (!string.IsNullOrEmpty(p_dataGridView.ExcelExportRowFilter))
                    {
                        if (p_dataGridView.DataSource.GetType().ToString() == "System.Data.DataSet")
                        {
                            if ((DataSet)p_dataGridView.DataSource == null)
                                dataTable1 = ((DataSet)p_dataGridView.DataSource).Tables[p_dataGridView.DataMember];
                            else if (p_dataGridView.DataMember != null && p_dataGridView.DataMember != "")
                            {
                                string[] strArray = p_dataGridView.DataMember.ToString().Split('.');
                                if (strArray.Length > 0)
                                {
                                    string index = strArray[strArray.Length - 1];
                                    dataTable1 = ((DataSet)p_dataGridView.DataSource).Relations[index] == null ? ((DataSet)p_dataGridView.DataSource).Tables[index] : ((DataSet)p_dataGridView.DataSource).Relations[index].ChildTable;
                                }
                            }
                        }
                        else
                            dataTable1 = (System.Data.DataTable)p_dataGridView.DataSource;
                        if (dataTable1 != null)
                        {
                            str2 = dataTable1.DefaultView.RowFilter;
                            dataTable1.DefaultView.RowFilter = p_dataGridView.ExcelExportRowFilter;
                        }
                    }
                    int num1 = !p_dataGridView.AllowUserToAddRows ? p_dataGridView.Rows.Count + 1 : p_dataGridView.Rows.Count;
                    application = (Microsoft.Office.Interop.Excel.Application)new ApplicationClass();
                    workbook = (_Workbook)application.Workbooks.Add((object)"workbook");
                    worksheet1 = (_Worksheet)workbook.ActiveSheet;
                    int index1 = 0;
                    int _colindex1 = 0;
                    int _colindex2 = 0;
                    Hashtable hashtable = new Hashtable();
                    for (int index2 = 0; index2 < dataTable2.Rows.Count; ++index2)
                    {
                        if (p_dataGridView.Columns.Contains(dataTable2.Rows[index2]["COLUMN_NAME"].ToString()))
                        {
                            ++_colindex2;
                            hashtable.Add((object)dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper(), (object)_colindex2);
                        }
                    }
                    object[,] objArray = new object[num1 + 1, _colindex2];
                    for (int index2 = 0; index2 < dataTable2.Rows.Count; ++index2)
                    {
                        if (p_dataGridView.Columns.Contains(dataTable2.Rows[index2]["COLUMN_NAME"].ToString()))
                        {
                            objArray[index1, _colindex1++] = !(dataTable2.Rows[index2]["EXCEL_HEADING"].ToString() != "") ? (object)p_dataGridView.Columns[dataTable2.Rows[index2]["COLUMN_NAME"].ToString()].HeaderText : (object)dataTable2.Rows[index2]["EXCEL_HEADING"].ToString();
                            if (dataTable2.Rows[index2]["COLUMN_AUTOFIT"].ToString() == "Y")
                                worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex1) + "1"), (object)(ExportUtility.ColumnName(_colindex1) + "1")).EntireColumn.AutoFit();
                            else if (dataTable2.Rows[index2]["COLUMN_WIDTH"].ToString() != "")
                                worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex1) + "1:" + ExportUtility.ColumnName(_colindex1) + num1.ToString()), System.Type.Missing).EntireColumn.ColumnWidth = (object)Convert.ToInt32(dataTable2.Rows[index2]["COLUMN_WIDTH"].ToString());
                        }
                    }
                    int _colindex3 = 1;
                    for (int index2 = 0; index2 < dataTable2.Rows.Count; ++index2)
                    {
                        if (hashtable.Contains((object)dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper()))
                        {
                            if (dataTable2.Rows[index2]["COLUMN_FORMAT"].ToString() != "")
                                worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex3) + "1"), (object)(ExportUtility.ColumnName(_colindex3) + "1")).EntireColumn.NumberFormat = (object)dataTable2.Rows[index2]["COLUMN_FORMAT"].ToString();
                            ++_colindex3;
                        }
                    }
                    foreach (DataGridViewRow dataGridViewRow in (IEnumerable)p_dataGridView.Rows)
                    {
                        ++index1;
                        int num2 = 0;
                        for (int index2 = 0; index2 < dataTable2.Rows.Count; ++index2)
                        {
                            if (hashtable.Contains((object)dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper()))
                            {
                                int num3 = dataGridViewRow.Cells[dataTable2.Rows[index2]["COLUMN_NAME"].ToString()].EditedFormattedValue == null ? 1 : (!dataGridViewRow.Cells[dataTable2.Rows[index2]["COLUMN_NAME"].ToString()].EditedFormattedValue.ToString().Contains("/") ? 1 : 0);
                                objArray[index1, num2++] = num3 != 0 ? dataGridViewRow.Cells[dataTable2.Rows[index2]["COLUMN_NAME"].ToString()].EditedFormattedValue : (object)("'" + dataGridViewRow.Cells[dataTable2.Rows[index2]["COLUMN_NAME"].ToString()].EditedFormattedValue.ToString());
                            }
                        }
                    }
                    int num4 = index1 + 1;
                    string str3 = string.Format("{0}:{1}", (object)"A1", (object)(ExportUtility.ColumnName(_colindex2) + num4.ToString()));
                    worksheet1.get_Range((object)str3, System.Type.Missing).Value2 = (object)objArray;
                    if (_dtGridOrder.Rows.Count > 0 && _dtGridOrder.Rows[0]["FONT_NAME"].ToString() != "")
                    {
                        FontStyle fontStyle;
                        switch (_dtGridOrder.Rows[0]["FONT_STYLE"].ToString())
                        {
                            case "Bold":
                                fontStyle = FontStyle.Bold;
                                break;
                            case "Italic":
                                fontStyle = FontStyle.Italic;
                                break;
                            case "Bold, Italic":
                                fontStyle = FontStyle.Bold | FontStyle.Italic;
                                break;
                            default:
                                fontStyle = FontStyle.Regular;
                                break;
                        }
                        string str4 = _dtGridOrder.Rows[0]["FONT_NAME"].ToString();
                        float num2 = float.Parse(_dtGridOrder.Rows[0]["FONT_SIZE"].ToString());
                        worksheet1.Cells.Font.Name = (object)str4;
                        worksheet1.Cells.Font.FontStyle = (object)fontStyle;
                        worksheet1.Cells.Font.Size = (object)num2;
                    }
                    string str5 = string.Empty;
                    string str6 = string.Empty;
                    string str7 = string.Empty;
                    string str8 = string.Empty;
                    string str9 = string.Empty;
                    string str10 = _dtGridOrder.Rows.Count == 0 || _dtGridOrder.Rows[0]["COLUMN_TOT_ROW_POS"].ToString() == "" ? "Bottom" : _dtGridOrder.Rows[0]["COLUMN_TOT_ROW_POS"].ToString();
                    int num5 = num4 + 1;
                    DataRow[] dataRowArray = _dtGridOrder.Select("COLUMN_SUMMARY is not null");
                    int num6 = 2;
                    int num7 = num5;
                    if (str10 == "Top" || str10 == "Both")
                    {
                        worksheet1.get_Range((object)"A1", (object)"A1").EntireRow.Insert(System.Type.Missing, System.Type.Missing);
                        num6 = 3;
                        num7 = num5 + 1;
                    }
                    int num8;
                    if (num6 != num7)
                    {
                        foreach (DataRow dataRow in dataRowArray)
                        {
                            string str4 = ExportUtility.ColumnName(int.Parse(hashtable[(object)dataRow["COLUMN_NAME"].ToString().ToUpper()].ToString()));
                            if (str10 == "Both")
                            {
                                str6 = string.Format("{0}:{1}", (object)(str4 + "1"), (object)(str4 + "1"));
                                str5 = string.Format("{0}:{1}", (object)(str4 + num7.ToString()), (object)(str4 + num7.ToString()));
                            }
                            else if (str10 == "Top")
                                str6 = string.Format("{0}:{1}", (object)(str4 + "1"), (object)(str4 + "1"));
                            else
                                str5 = string.Format("{0}:{1}", (object)(str4 + num7.ToString()), (object)(str4 + num7.ToString()));
                            switch (dataRow["COLUMN_SUMMARY"].ToString())
                            {
                                case "Sum":
                                    string[] strArray1 = new string[8]
                  {
                    "=SUBTOTAL(9,",
                    str4,
                    num6.ToString(),
                    ":",
                    str4,
                    "",
                    null,
                    null
                  };
                                    string[] strArray2 = strArray1;
                                    int index2 = 6;
                                    num8 = num7 - 1;
                                    string str11 = num8.ToString();
                                    strArray2[index2] = str11;
                                    strArray1[7] = ")";
                                    string str12 = string.Concat(strArray1);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str12;
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str12;
                                        break;
                                    }
                                    break;
                                case "Min":
                                    string[] strArray3 = new string[8]
                  {
                    "=SUBTOTAL(5,",
                    str4,
                    num6.ToString(),
                    ":",
                    str4,
                    "",
                    null,
                    null
                  };
                                    string[] strArray4 = strArray3;
                                    int index3 = 6;
                                    num8 = num7 - 1;
                                    string str13 = num8.ToString();
                                    strArray4[index3] = str13;
                                    strArray3[7] = ")";
                                    string str14 = string.Concat(strArray3);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str14;
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str14;
                                        break;
                                    }
                                    break;
                                case "Max":
                                    string[] strArray5 = new string[8]
                  {
                    "=SUBTOTAL(4,",
                    str4,
                    num6.ToString(),
                    ":",
                    str4,
                    "",
                    null,
                    null
                  };
                                    string[] strArray6 = strArray5;
                                    int index4 = 6;
                                    num8 = num7 - 1;
                                    string str15 = num8.ToString();
                                    strArray6[index4] = str15;
                                    strArray5[7] = ")";
                                    string str16 = string.Concat(strArray5);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str16;
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str16;
                                        break;
                                    }
                                    break;
                                case "Avg":
                                    string[] strArray7 = new string[15];
                                    strArray7[0] = "=SUBTOTAL(9,";
                                    strArray7[1] = str4;
                                    strArray7[2] = num6.ToString();
                                    strArray7[3] = ":";
                                    strArray7[4] = str4;
                                    strArray7[5] = "";
                                    string[] strArray8 = strArray7;
                                    int index5 = 6;
                                    num8 = num7 - 1;
                                    string str17 = num8.ToString();
                                    strArray8[index5] = str17;
                                    strArray7[7] = ")/SUBTOTAL(3,";
                                    strArray7[8] = str4;
                                    strArray7[9] = num6.ToString();
                                    strArray7[10] = ":";
                                    strArray7[11] = str4;
                                    strArray7[12] = "";
                                    string[] strArray9 = strArray7;
                                    int index6 = 13;
                                    num8 = num7 - 1;
                                    string str18 = num8.ToString();
                                    strArray9[index6] = str18;
                                    strArray7[14] = ")";
                                    string str19 = string.Concat(strArray7);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str19;
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str19;
                                        break;
                                    }
                                    break;
                                case "Count":
                                    string[] strArray10 = new string[8]
                  {
                    "=SUBTOTAL(3,",
                    str4,
                    num6.ToString(),
                    ":",
                    str4,
                    "",
                    null,
                    null
                  };
                                    string[] strArray11 = strArray10;
                                    int index7 = 6;
                                    num8 = num7 - 1;
                                    string str20 = num8.ToString();
                                    strArray11[index7] = str20;
                                    strArray10[7] = ")";
                                    string str21 = string.Concat(strArray10);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str21;
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str21;
                                        break;
                                    }
                                    break;
                                case "Weighted Avg":
                                    string str22 = ExportUtility.ColumnName(int.Parse(hashtable[(object)dataRow["COLUMN_WGT_SUMM"].ToString()].ToString()));
                                    if (hashtable[(object)dataRow["COLUMN_WGT_SUMM2"].ToString()] == null || hashtable[(object)dataRow["COLUMN_WGT_SUMM2"].ToString()].ToString() == "")
                                    {
                                        string[] strArray12 = new string[20];
                                        strArray12[0] = "=SUMPRODUCT(";
                                        strArray12[1] = str4;
                                        strArray12[2] = num6.ToString();
                                        strArray12[3] = ":";
                                        strArray12[4] = str4;
                                        string[] strArray13 = strArray12;
                                        int index8 = 5;
                                        num8 = num7 - 1;
                                        string str23 = num8.ToString();
                                        strArray13[index8] = str23;
                                        strArray12[6] = "*";
                                        strArray12[7] = str22;
                                        strArray12[8] = num6.ToString();
                                        strArray12[9] = ":";
                                        strArray12[10] = str22;
                                        string[] strArray14 = strArray12;
                                        int index9 = 11;
                                        num8 = num7 - 1;
                                        string str24 = num8.ToString();
                                        strArray14[index9] = str24;
                                        strArray12[12] = ")/SUM(";
                                        strArray12[13] = str22;
                                        strArray12[14] = num6.ToString();
                                        strArray12[15] = ":";
                                        strArray12[16] = str22;
                                        strArray12[17] = "";
                                        string[] strArray15 = strArray12;
                                        int index10 = 18;
                                        num8 = num7 - 1;
                                        string str25 = num8.ToString();
                                        strArray15[index10] = str25;
                                        strArray12[19] = ")";
                                        string str26 = string.Concat(strArray12);
                                        if (!string.IsNullOrEmpty(str6))
                                            worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str26;
                                        if (!string.IsNullOrEmpty(str5))
                                        {
                                            worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str26;
                                            break;
                                        }
                                        break;
                                    }
                                    string str27 = ExportUtility.ColumnName(int.Parse(hashtable[(object)dataRow["COLUMN_WGT_SUMM2"].ToString()].ToString()));
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)("=" + str27 + "1/" + str22 + "1");
                                    if (!string.IsNullOrEmpty(str5))
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)("=" + str27 + num7.ToString() + "/" + str22 + num7.ToString());
                                    break;
                                case "Weighted Disc":
                                    string str28 = ExportUtility.ColumnName(int.Parse(hashtable[(object)dataRow["COLUMN_WGT_SUMM"].ToString()].ToString()));
                                    string str29 = ExportUtility.ColumnName(int.Parse(hashtable[(object)dataRow["COLUMN_WGT_SUMM2"].ToString()].ToString()));
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)("=((" + str29 + "1 - " + str28 + "1 )/" + str29 + "1)*100");
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)("=((" + str29 + num7.ToString() + " - " + str28 + num7.ToString() + " )/" + str29 + num7.ToString() + ")*100");
                                        break;
                                    }
                                    break;
                            }
                        }
                        if (p_dataGridView.TotalCol != null)
                        {
                            foreach (string str4 in p_dataGridView.TotalCol)
                            {
                                if (_dtGridOrder.Select("COLUMN_SUMMARY is not null and COLUMN_NAME='" + str4 + "'").Length == 0 && hashtable.Contains((object)str4.ToUpper()))
                                {
                                    string str11 = ExportUtility.ColumnName(int.Parse(hashtable[(object)str4.ToUpper()].ToString()));
                                    if (str10 == "Both")
                                    {
                                        str6 = string.Format("{0}:{1}", (object)(str11 + "1"), (object)(str11 + "1"));
                                        str5 = string.Format("{0}:{1}", (object)(str11 + num7.ToString()), (object)(str11 + num7.ToString()));
                                    }
                                    else if (str10 == "Top")
                                        str6 = string.Format("{0}:{1}", (object)(str11 + "1"), (object)(str11 + "1"));
                                    else
                                        str5 = string.Format("{0}:{1}", (object)(str11 + num7.ToString()), (object)(str11 + num7.ToString()));
                                    string[] strArray1 = new string[8]
                  {
                    "=SUBTOTAL(9,",
                    str11,
                    num6.ToString(),
                    ":",
                    str11,
                    "",
                    null,
                    null
                  };
                                    string[] strArray2 = strArray1;
                                    int index2 = 6;
                                    num8 = num7 - 1;
                                    string str12 = num8.ToString();
                                    strArray2[index2] = str12;
                                    strArray1[7] = ")";
                                    string str13 = string.Concat(strArray1);
                                    if (!string.IsNullOrEmpty(str6))
                                        worksheet1.get_Range((object)str6, System.Type.Missing).Value2 = (object)str13;
                                    if (!string.IsNullOrEmpty(str5))
                                        worksheet1.get_Range((object)str5, System.Type.Missing).Value2 = (object)str13;
                                }
                            }
                        }
                    }
                    int _colindex4 = 1;
                    for (int index2 = 0; index2 < dataTable2.Rows.Count; ++index2)
                    {
                        if (hashtable.Contains((object)dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper()))
                        {
                            if (dataTable2.Rows[index2]["COLUMN_AUTOFIT"].ToString() == "Y")
                                worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex4) + "1"), (object)(ExportUtility.ColumnName(_colindex4) + "1")).EntireColumn.AutoFit();
                            else if (dataTable2.Rows[index2]["COLUMN_WIDTH"].ToString() != "")
                                worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex4) + "1:" + ExportUtility.ColumnName(_colindex4) + num1.ToString()), System.Type.Missing).EntireColumn.ColumnWidth = (object)Convert.ToInt32(dataTable2.Rows[index2]["COLUMN_WIDTH"].ToString());
                            if (dataTable2.Rows[index2]["COLUMN_FORMAT"].ToString() == "" && p_dataGridView.Columns[dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper()].ValueType == typeof(Decimal) && p_dataGridView.DecimalCol != null)
                            {
                                string str4 = "null";
                                for (int index3 = 0; index3 < p_dataGridView.DecimalCol.Length; ++index3)
                                {
                                    if (p_dataGridView.DecimalCol[index3].Trim().ToUpper().Contains(dataTable2.Rows[index2]["COLUMN_NAME"].ToString().ToUpper()))
                                    {
                                        if (p_dataGridView.DecimalCol[index3].Trim().ToUpper().Contains(","))
                                        {
                                            string[] strArray = p_dataGridView.DecimalCol[index3].Split(',');
                                            str4 = !(strArray[1].Trim() != "") ? "0.00" : "0." + "".PadRight(int.Parse(strArray[1]), '0');
                                            break;
                                        }
                                        str4 = "0.00";
                                    }
                                }
                                if (str4 != "null")
                                    worksheet1.get_Range((object)(ExportUtility.ColumnName(_colindex4) + "1"), (object)(ExportUtility.ColumnName(_colindex4) + "1")).EntireColumn.NumberFormat = (object)str4;
                            }
                            ++_colindex4;
                        }
                    }
                    if (str10 == "Both" || str10 == "Top")
                    {
                        worksheet1.get_Range((object)"A1", (object)"A1").EntireRow.Insert(System.Type.Missing, System.Type.Missing);
                        worksheet1.get_Range((object)"A2", (object)"A2").EntireRow.Copy(System.Type.Missing);
                        worksheet1.get_Range((object)"A1", (object)"A1").EntireRow.PasteSpecial(XlPasteType.xlPasteFormulas, XlPasteSpecialOperation.xlPasteSpecialOperationNone, (object)false, (object)false);
                        for (int _colindex5 = 1; _colindex5 <= _colindex4; ++_colindex5)
                        {
                            string str4 = ExportUtility.ColumnName(_colindex5);
                            object obj = worksheet1.get_Range((object)(str4 + "2"), (object)(str4 + "2")).Formula;
                            if (obj != null && obj.ToString() != "")
                            {
                                if (!obj.ToString().Contains(":"))
                                    obj = worksheet1.get_Range((object)(str4 + "1"), (object)(str4 + "1")).Formula;
                                if (obj.ToString().Contains("SUBTOTAL(3,"))
                                    obj = (object)obj.ToString().Replace("SUBTOTAL(3,", "COUNTA(");
                                else if (obj.ToString().Contains("SUBTOTAL(4,"))
                                    obj = (object)obj.ToString().Replace("SUBTOTAL(4,", "MAX(");
                                if (obj.ToString().Contains("SUBTOTAL(5,"))
                                    obj = (object)obj.ToString().Replace("SUBTOTAL(5,", "MIN(");
                                if (obj.ToString().Contains("SUBTOTAL(9,"))
                                    obj = (object)obj.ToString().Replace("SUBTOTAL(9,", "SUM(");
                                worksheet1.get_Range((object)(str4 + "1"), (object)(str4 + "1")).Value2 = obj;
                            }
                        }
                        _Worksheet worksheet2 = worksheet1;
                        string str11 = "A" + num6.ToString();
                        string str12 = ExportUtility.ColumnName(_colindex4 - 1);
                        num8 = num1 + 2;
                        string str13 = num8.ToString();
                        string str14 = str12 + str13;
                        worksheet2.get_Range((object)str11, (object)str14).Borders.Value = (object)1;
                        worksheet1.get_Range((object)("A" + (object)num6), (object)(ExportUtility.ColumnName(_colindex4) + (object)num6)).EntireRow.Font.Bold = (object)true;
                    }
                    else
                    {
                        _Worksheet worksheet2 = worksheet1;
                        string str4 = "A";
                        num8 = num6 - 1;
                        string str11 = num8.ToString();
                        string str12 = str4 + str11;
                        string str13 = ExportUtility.ColumnName(_colindex4 - 1);
                        num8 = num1 + 1;
                        string str14 = num8.ToString();
                        string str15 = str13 + str14;
                        worksheet2.get_Range((object)str12, (object)str15).Borders.Value = (object)1;
                        worksheet1.get_Range((object)("A" + (object)(num6 - 1)), (object)(ExportUtility.ColumnName(_colindex4) + (object)(num6 - 1))).EntireRow.Font.Bold = (object)true;
                    }
                    worksheet1.PageSetup.Orientation = XlPageOrientation.xlLandscape;
                    worksheet1.PageSetup.LeftMargin = worksheet1.PageSetup.Application.InchesToPoints(0.1);
                    worksheet1.PageSetup.RightMargin = worksheet1.PageSetup.Application.InchesToPoints(0.0);
                    worksheet1.PageSetup.FooterMargin = worksheet1.PageSetup.Application.InchesToPoints(0.0);
                    worksheet1.PageSetup.HeaderMargin = worksheet1.PageSetup.Application.InchesToPoints(0.0);
                    worksheet1.PageSetup.TopMargin = worksheet1.PageSetup.Application.InchesToPoints(0.3);
                    worksheet1.PageSetup.BottomMargin = worksheet1.PageSetup.Application.InchesToPoints(0.0);
                    worksheet1.PageSetup.Zoom = (object)false;
                    worksheet1.PageSetup.FitToPagesWide = (object)1;
                    worksheet1.PageSetup.FitToPagesTall = (object)false;
                    worksheet1.PageSetup.PrintGridlines = true;
                    if (p_with_priview)
                    {
                        workbook.SaveAs((object)str1, (object)XlFileFormat.xlWorkbookNormal, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, XlSaveAsAccessMode.xlNoChange, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
                        if (MessageBox.Show("Exported Successfully, Do you want to open Preview?", "Excel Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            application.Visible = true;
                            worksheet1.PrintPreview((object)true);
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Exported Successfully, Do you want to open file?", "Excel Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            application.Visible = true;
                        workbook.SaveAs((object)str1, (object)XlFileFormat.xlWorkbookNormal, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, XlSaveAsAccessMode.xlNoChange, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
                    }
                }
                return str1;

            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
                return (string)null;
            }
            finally
            {

                if (str2 != "Not Assigned")
                    dataTable1.DefaultView.RowFilter = str2;
                if (application != null)
                    Marshal.ReleaseComObject((object)application);
                if (worksheet1 != null)
                    Marshal.ReleaseComObject((object)worksheet1);
                if (workbook != null)
                    Marshal.ReleaseComObject((object)workbook);
            }
             *
             */
            return null;
        }
        public static void ExcelOfficeConverter(GridViewControl p_dataGridView)
        {
            try
            {
                /*
                int num1 = !p_dataGridView.AllowUserToAddRows ? p_dataGridView.Rows.Count + 1 : p_dataGridView.Rows.Count;
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Excel Spreadsheets (*.xlsx)|*.xlsx|xls (*.xls)|*.xls";
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                string fileName = saveFileDialog.FileName;
                Microsoft.Office.Interop.Excel.Application application = (Microsoft.Office.Interop.Excel.Application)new ApplicationClass();
                Workbook workbook = application.Workbooks.Add(System.Type.Missing);
                Worksheet worksheet = (Worksheet)application.Sheets.get_Item((object)1);
                int index1 = 0;
                int num2 = 0;
                int _colindex = 0;
                Hashtable hashtable = new Hashtable();
                for (int index2 = 0; index2 < p_dataGridView.Columns.Count; ++index2)
                {
                    if (p_dataGridView.Columns[index2].Visible)
                    {
                        ++_colindex;
                        hashtable.Add((object)p_dataGridView.Columns[index2].Name.ToUpper(), (object)_colindex);
                    }
                }
                object[,] objArray = new object[num1 + 1, _colindex];
                for (int index2 = 0; index2 < p_dataGridView.Columns.Count; ++index2)
                {
                    if (p_dataGridView.Columns[index2].Visible)
                        objArray[index1, num2++] = (object)p_dataGridView.Columns[index2].HeaderText;
                }
                foreach (DataGridViewRow dataGridViewRow in (IEnumerable)p_dataGridView.Rows)
                {
                    ++index1;
                    int num3 = 0;
                    for (int index2 = 0; index2 < p_dataGridView.Columns.Count; ++index2)
                    {
                        if (p_dataGridView.Columns[index2].Visible)
                            objArray[index1, num3++] = dataGridViewRow.Cells[index2].EditedFormattedValue;
                    }
                }
                int num4 = index1 + 1;
                string str1 = string.Format("{0}:{1}", (object)"A1", (object)(ExportUtility.ColumnName(_colindex) + num4.ToString()));
                worksheet.get_Range((object)str1, System.Type.Missing).Value2 = (object)objArray;
                string str2 = string.Empty;
                int num5 = num4 + 1;
                if (p_dataGridView.TotalCol != null)
                {
                    foreach (string str3 in p_dataGridView.TotalCol)
                    {
                        if (hashtable.Contains((object)str3.ToUpper()))
                        {
                            string str4 = ExportUtility.ColumnName(int.Parse(hashtable[(object)str3.ToUpper()].ToString()));
                            string str5 = string.Format("{0}:{1}", (object)(str4 + num5.ToString()), (object)(str4 + num5.ToString()));
                            worksheet.get_Range((object)str5, System.Type.Missing).Value2 = (object)("=SUM(" + str4 + "2:" + str4 + "" + (num5 - 1).ToString() + ")");
                        }
                    }
                }
                workbook.Close((object)true, (object)fileName, System.Type.Missing);
                */
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void ExcelConverter(GridViewControl p_dataGridView)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Excel Spreadsheets (*.xls)|*.xls";
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                string fileName = saveFileDialog.FileName;
                StringBuilder stringBuilder = new StringBuilder();
                StreamWriter text = File.CreateText(fileName);
                int num = 0;
                if (ExportUtility._ShowExcelTableBorder)
                    num = 1;
                string str1 = "";
                string str2 = "";
                if (ExportUtility._ExcelHeaderBold)
                {
                    str1 = "<B>";
                    str2 = "</B>";
                }
                stringBuilder.Append("<Table border=" + (object)num + ">");
                stringBuilder.Append("<TR>");
                foreach (DataGridViewColumn dataGridViewColumn in (BaseCollection)p_dataGridView.Columns)
                {
                    if (dataGridViewColumn.Visible)
                        stringBuilder.Append("<TD>" + str1 + dataGridViewColumn.HeaderText + str2 + "</TD>");
                }
                stringBuilder.Append("</TR>");
                foreach (DataGridViewRow dataGridViewRow in (IEnumerable)p_dataGridView.Rows)
                {
                    stringBuilder.Append("<TR>");
                    foreach (DataGridViewColumn dataGridViewColumn in (BaseCollection)p_dataGridView.Columns)
                    {
                        if (dataGridViewColumn.Visible)
                        {
                            string str3 = "String";
                            if (p_dataGridView.NumericCol != null && p_dataGridView.NumericCol.Length > 0 && ExportUtility.FindElement(dataGridViewColumn.Name, p_dataGridView.NumericCol, true) != -1)
                                str3 = "Numeric";
                            else if (p_dataGridView.DecimalCol != null && p_dataGridView.DecimalCol.Length > 0 && ExportUtility.FindElement(dataGridViewColumn.Name, p_dataGridView.DecimalCol, false) != -1)
                                str3 = "Decimal";
                            else if (p_dataGridView.DateTimeCol != null && p_dataGridView.DateTimeCol.Length > 0 && ExportUtility.FindElement(dataGridViewColumn.Name, p_dataGridView.DateTimeCol, true) != -1)
                                str3 = "DateTime";
                            if (dataGridViewRow.Cells[dataGridViewColumn.Name].ValueType.ToString() == "System.DateTime")
                            {
                                if (str3 == "DateTime")
                                    stringBuilder.Append("<TD style=mso-number-format:dd-mm-yyyy hh:mm:ss>" + dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue.ToString() + "</TD>");
                                else
                                    stringBuilder.Append("<TD style=mso-number-format:dd-mm-yyyy>" + dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue.ToString() + "</TD>");
                            }
                            else if (str3 == "String")
                                stringBuilder.Append("<TD style= mso-number-format:\\@>" + dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue.ToString() + "</TD>");
                            else if (str3 == "Numeric")
                                stringBuilder.Append("<TD style= mso-number-format:##; align=right >" + dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue + "</TD>");
                            else if (str3 == "Decimal")
                                stringBuilder.Append("<TD style= mso-number-format:0/0.000; align=right>" + dataGridViewRow.Cells[dataGridViewColumn.Name].EditedFormattedValue + "</TD>");
                        }
                    }
                    stringBuilder.Append("</TR>");
                }
                stringBuilder.Append("<TR>");
                if (p_dataGridView.TotalCol != null)
                {
                    foreach (DataGridViewColumn dataGridViewColumn in (BaseCollection)p_dataGridView.Columns)
                    {
                        if (dataGridViewColumn.Visible)
                        {
                            if (ExportUtility.FindElement(dataGridViewColumn.Name.ToString(), p_dataGridView.TotalCol, true) != -1)
                                stringBuilder.Append("<TD align=right><B>" + (object)p_dataGridView.GetTotalValue(dataGridViewColumn.Name) + "</B></TD>");
                            else
                                stringBuilder.Append("<TD> </TD>");
                        }
                    }
                }
                stringBuilder.Append("</TR>");
                stringBuilder.Append("</Table>");
                text.WriteLine(stringBuilder.ToString());
                text.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
        }