Пример #1
0
        public ExcelHlper(string FileName, string[] SheetNames)
        {
            this.FileName = FileName;

            try
            {
                App         = new Excel.Application();
                App.Visible = false;
                Worksheets  = new Dictionary <string, Excel.Worksheet>();
                var xlBook = App.Workbooks.Open(@"" + Ico.getValue <IO>().GetTemplatesPath() + "\\" + FileName + ".xlsx");
                foreach (string SheetName in SheetNames)
                {
                    Worksheets[SheetName] = (Microsoft.Office.Interop.Excel.Worksheet)xlBook.Worksheets.get_Item(SheetName); // Explicit cast is not required here
                }
            }
            catch (Exception e) {
                App.Quit();
            }
        }
Пример #2
0
        public Date()
        {
            var d  = DateTime.Now;
            var dn = Ico.getValue <db>().GetUnivdb().years.ToList().Where(Y => Y.year1.Year == d.Year).ToList().SingleOrDefault();

            if (dn != null)
            {
                this._date = dn;
            }
            else
            {
                this._date = Ico.getValue <db>().GetUnivdb().years.Add(new year()
                {
                    year1 = d
                });
                Ico.getValue <db>().savedb();
            }
            this._prev_date = Ico.getValue <db>().GetUnivdb().years.ToList().Where(Y => Y.year1.Year == (d.Year - 1)).ToList().SingleOrDefault();
        }
Пример #3
0
        public void SaveAs(string pathSAVE)
        {
            var p = pathSAVE + ".xlsx";

            try
            {
                if (System.IO.File.Exists(p))
                {
                    System.IO.File.Delete(p);
                }
            }
            catch (Exception e) {
                Ico.getValue <ContentApp>().OpenSample4Dialog();
                Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> {
                    "هنالك خطأ في العملية الرجاء التأكد الملف ليس قيد الاستخدام "
                }, Ico.getValue <ContentApp>().CancelSample4Dialog);

                Thread.CurrentThread.Abort();
            }
            App.ActiveWorkbook.SaveAs(p);
        }