コード例 #1
0
        // Function  : ExportDetails
        // Arguments : DetailsTable, FormatType, FileName
        // Purpose	 : To get all the column headers in the datatable and
        //			   exorts in CSV / Excel format with all columns

        internal void ExportDetails
            (DataTable detailsTable,
            ExportFormat FormatType,
            string FileName)
        {
            try
            {
                if (detailsTable.Rows.Count == 0)
                {
                    throw new Exception
                              ("There are no details to export.");
                }


                // Create Dataset

                DataSet   dsExport = new DataSet("Export");
                DataTable dtExport = detailsTable.Copy();

                dtExport.TableName = "Values";

                dsExport.Tables.Add(dtExport);

                // Getting Field Names
                string[] sHeaders = new string[dtExport.Columns.Count];
                string[] sFileds  = new string[dtExport.Columns.Count];

                for (int i = 0; i < dtExport.Columns.Count; i++)
                {
                    //sHeaders[i] = ReplaceSpclChars(dtExport.Columns[i].ColumnName);
                    sHeaders[i] = dtExport.Columns[i].ColumnName;
                    sFileds[i]  = ReplaceSpecialCharacters(dtExport.Columns[i].ColumnName);
                }

                if (_appType == "Web")
                {
                    WebXsltExporter.ExportWithXsltWeb
                        (dsExport, sHeaders, sFileds,
                        FormatType, FileName);
                }

                if (_appType == "Win")
                {
                    LocalXsltExporter.ExportWithXsltWindows
                        (dsExport, sHeaders, sFileds,
                        FormatType, FileName);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
コード例 #2
0
        private void PerformXsltExport
            (string[] headers, ExportFormat formatType,
            string fileName, DataSet dsExport, string[] sFileds)
        {
            if (_appType == "Web")
            {
                WebXsltExporter.ExportWithXsltWeb
                    (dsExport, headers, sFileds, formatType, fileName);
            }

            if (_appType == "Win")
            {
                LocalXsltExporter.ExportWithXsltWindows
                    (dsExport, headers, sFileds, formatType, fileName);
            }
        }
コード例 #3
0
        // Function  : ExportDetails
        // Arguments : DetailsTable, ColumnList, FormatType, FileName
        // Purpose	 : To get the specified column headers in the datatable and
        //			   exorts in CSV / Excel format with specified columns


        internal void ExportDetails
            (DataTable detailsTable,
            int[] columnList, ExportFormat FormatType,
            string FileName)
        {
            try
            {
                if (detailsTable.Rows.Count == 0)
                {
                    throw new Exception
                              ("There are no details to export");
                }

                // Create Dataset
                DataSet dsExport = new DataSet("Export");

                DataTable dtExport = detailsTable.Copy();

                dtExport.TableName = "Values";

                dsExport.Tables.Add(dtExport);

                if (columnList.Length > dtExport.Columns.Count)
                {
                    throw new Exception
                              ("ExportColumn List should not exceed Total Columns");
                }


                // Getting Field Names
                var sHeaders = new string[columnList.Length];
                var sFileds  = new string[columnList.Length];


                for (int i = 0; i < columnList.Length; i++)
                {
                    if ((columnList[i] < 0) ||
                        (columnList[i] >= dtExport.Columns.Count))
                    {
                        throw new Exception
                                  ("ExportColumn Number should not exceed Total Columns Range");
                    }

                    sHeaders[i] = dtExport.Columns[columnList[i]].ColumnName;
                    sFileds[i]  = ReplaceSpecialCharacters(dtExport.Columns[columnList[i]].ColumnName);
                }


                switch (_appType)
                {
                case "Web":
                    WebXsltExporter.ExportWithXsltWeb
                        (dsExport, sHeaders, sFileds,
                        FormatType, FileName);
                    break;

                case "Win":
                    LocalXsltExporter.ExportWithXsltWindows
                        (dsExport, sHeaders, sFileds,
                        FormatType, FileName);
                    break;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }