public void read(ref List<string> grpname , ref List<string> path)
        {
            createfile objcf = new createfile();
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;
            object missing = System.Reflection.Missing.Value;

            xlApp = new Excel.Application();

            xlWorkBook = xlApp.Workbooks.Open(@"d:\database\Group.xlsx", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range = xlWorkSheet.UsedRange;
            int i = 0;
            string str,str1;
            for (int rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
            {
                str = (string)(range.Cells[rCnt, 1] as Excel.Range).Value2;
                str1 = (string)(range.Cells[rCnt, 2] as Excel.Range).Value2;
                grpname.Add(str);
                path.Add(str1);

            }
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
        public void add(string path, string name, string phoneno,string Email,string type,string gname)
        {
            createfile objcf = new createfile();
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;
            object missing = System.Reflection.Missing.Value;

            xlApp = new Excel.Application();

            xlWorkBook = xlApp.Workbooks.Open(path, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range = xlWorkSheet.UsedRange;

              //  MessageBox.Show(_lastRow.ToString());
                xlWorkSheet.Cells[range.Rows.Count+1, 1] = name;
                xlWorkSheet.Cells[range.Rows.Count+1, 2] = phoneno;
                xlWorkSheet.Cells[range.Rows.Count+1, 3] = Email;
                xlWorkSheet.Cells[range.Rows.Count+1, 4] = type;
                xlWorkSheet.Cells[range.Rows.Count+1, 5] = gname;

            xlWorkBook.Save();

            xlWorkBook.Close();

            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
示例#3
0
        public void read(ref List <string> grpname, ref List <string> path)
        {
            createfile objcf = new createfile();

            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Range       range;
            object            missing = System.Reflection.Missing.Value;



            xlApp = new Excel.Application();

            xlWorkBook  = xlApp.Workbooks.Open(@"d:\database\Group.xlsx", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range       = xlWorkSheet.UsedRange;
            int    i = 0;
            string str, str1;

            for (int rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
            {
                str  = (string)(range.Cells[rCnt, 1] as Excel.Range).Value2;
                str1 = (string)(range.Cells[rCnt, 2] as Excel.Range).Value2;
                grpname.Add(str);
                path.Add(str1);
            }
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
        public void update(string gname, string path)
        {
            createfile objcf = new createfile();

            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Range       range;
            object            missing = System.Reflection.Missing.Value;



            xlApp = new Excel.Application();

            xlWorkBook  = xlApp.Workbooks.Open(@"d:\database\Group.xlsx", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range       = xlWorkSheet.UsedRange;
            xlWorkSheet.Cells[range.Rows.Count + 1, 1] = gname;
            xlWorkSheet.Cells[range.Rows.Count + 1, 2] = path;
            xlWorkBook.Save();

            xlWorkBook.Close();

            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
        public void read(string path, ref List<string> name, ref List<string> phone, ref List<string> email,ref List<string> gname)
        {
            createfile objcf = new createfile();
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;
            object missing = System.Reflection.Missing.Value;

            xlApp = new Excel.Application();

            xlWorkBook = xlApp.Workbooks.Open(path, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range = xlWorkSheet.UsedRange;

            string str,str1,str2,str3;
            for (int rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
            {
                str = (string)(range.Cells[rCnt, 1] as Excel.Range).Value2;
                str1 = (string)((range.Cells[rCnt, 2] as Excel.Range).Value2).ToString();
                str2 = (string)(range.Cells[rCnt, 3] as Excel.Range).Value2;
                str3 = (string)(range.Cells[rCnt, 5] as Excel.Range).Value2;
                name.Add(str);
                phone.Add(str1);
                email.Add(str2);
                gname.Add(str3);
            }
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
        public void update(string gname,string path)
        {
            createfile objcf = new createfile();
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;
            object missing = System.Reflection.Missing.Value;

            xlApp = new Excel.Application();

            xlWorkBook = xlApp.Workbooks.Open(@"d:\database\Group.xlsx", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range = xlWorkSheet.UsedRange;
            xlWorkSheet.Cells[range.Rows.Count + 1, 1] = gname;
            xlWorkSheet.Cells[range.Rows.Count + 1, 2] = path;
            xlWorkBook.Save();

            xlWorkBook.Close();

            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
示例#7
0
        public void read(string path, ref List <string> name, ref List <string> phone, ref List <string> email, ref List <string> gname)
        {
            createfile objcf = new createfile();

            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Range       range;
            object            missing = System.Reflection.Missing.Value;



            xlApp = new Excel.Application();

            xlWorkBook  = xlApp.Workbooks.Open(path, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range       = xlWorkSheet.UsedRange;

            string str, str1, str2, str3;

            for (int rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
            {
                str  = (string)(range.Cells[rCnt, 1] as Excel.Range).Value2;
                str1 = (string)((range.Cells[rCnt, 2] as Excel.Range).Value2).ToString();
                str2 = (string)(range.Cells[rCnt, 3] as Excel.Range).Value2;
                str3 = (string)(range.Cells[rCnt, 5] as Excel.Range).Value2;
                name.Add(str);
                phone.Add(str1);
                email.Add(str2);
                gname.Add(str3);
            }
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }
示例#8
0
        public void add(string path, string name, string phoneno, string Email, string type, string gname)
        {
            createfile objcf = new createfile();

            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Range       range;
            object            missing = System.Reflection.Missing.Value;



            xlApp = new Excel.Application();

            xlWorkBook  = xlApp.Workbooks.Open(path, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, true, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range       = xlWorkSheet.UsedRange;



            //  MessageBox.Show(_lastRow.ToString());
            xlWorkSheet.Cells[range.Rows.Count + 1, 1] = name;
            xlWorkSheet.Cells[range.Rows.Count + 1, 2] = phoneno;
            xlWorkSheet.Cells[range.Rows.Count + 1, 3] = Email;
            xlWorkSheet.Cells[range.Rows.Count + 1, 4] = type;
            xlWorkSheet.Cells[range.Rows.Count + 1, 5] = gname;

            xlWorkBook.Save();

            xlWorkBook.Close();

            xlApp.Quit();

            objcf.releaseObject(xlWorkSheet);
            objcf.releaseObject(xlWorkBook);
            objcf.releaseObject(xlApp);
        }