Beispiel #1
0
        public void ExportToExcel(System.Data.DataTable dataTable, Application excel, Workbook workBook)
        {
            FetchFiles ff        = new FetchFiles();
            Worksheet  workSheet = workBook.ActiveSheet;
            int        Column    = workSheet.UsedRange.Columns.Count - 1;
            int        Column1   = Column;
            int        Column2   = Column;

            foreach (DataColumn dc in dataTable.Columns)
            {
                Column++;
                excel.Cells[1, Column] = dc.ColumnName;
            }

            foreach (DataRow datarow in dataTable.Rows)
            {
                int mainRow = 0;
                mainRow++;

                foreach (DataColumn dataColumn in dataTable.Columns)
                {
                    Column1++;
                    excel.Cells[mainRow + 1, Column1] = datarow[dataColumn.ColumnName];
                }

                Column1 = Column2;
            }

            workSheet.Activate();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workSheet);
        }
Beispiel #2
0
        static void Main()
        {
            List <string> awsUrl          = new List <string>();
            string        urlFile         = ConfigurationManager.AppSettings["TargetUrlFile"];
            string        destinationPath = ConfigurationManager.AppSettings["outPutFilePath"];

            Console.WriteLine("Extracting Data, Might Take Some Time \n");
            FetchFiles fetchAwsFiles = new FetchFiles();

            //ds--fetch xml aws urls from TargetUrlFile
            using (var reader = new StreamReader(urlFile))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    awsUrl.Add(line);
                }
            }

            //ds--store all the urls as an array
            string[] urlArray = awsUrl.ToArray();

            //ds--fetch all aws data in a new excel
            fetchAwsFiles.FetchData(urlArray, destinationPath);

            //ds--Also can call IXport as XML class to save as an XML
            Console.WriteLine("\n \nProcess Complete");
            Console.ReadKey();
        }