예제 #1
0
        private void TKBNgayLopForm_Load(object sender, EventArgs e)
        {
            this.Text = "Thời khoá biểu lớp " + Lop.ten + " - " + ngay.ToString("dd/MM/yyyy");

            using (FileStream stream = new FileStream("TKB_Ngay_Theo_Lop.xlsx", FileMode.Open))
            {
                Xlsx.LoadDocument(stream, DocumentFormat.Xlsx);
                wb = Xlsx.Document;
            }

            Worksheet ws = wb.Worksheets[0];

            ws.Name = "TKB_ngay_" + ngay.ToString("dd-MM-yyyy") + "_lop_" + Lop.ten;
            Cell             cell       = ws[0, 0];
            TkbNgayLopHelper tKB_helper = new TkbNgayLopHelper(ws, Lop, tietHocs, ngay, size, cell);

            tKB_helper.setBackground();

            IEnumerable <Cell> cells = ws.Search("_trucBan");

            foreach (Cell c in cells)
            {
                c.Value = trucBan;
            }
            tKB_helper.xep();
            done = true;
        }
        private async void TkbNgayTatCaLopForm_Load(object sender, EventArgs e)
        {
            this.Text = "Thời khoá biểu các lớp ngày " + ngay.ToString("dd/MM/yyyy");

            using (FileStream stream = new FileStream("TKB_Ngay_Tat_Ca_Lop.xlsx", FileMode.Open))
            {
                xlsxViewer.LoadDocument(stream, DocumentFormat.Xlsx);
                wb = xlsxViewer.Document;
                ws = wb.Worksheets[0];
            }

            IEnumerable <Cell> cells = ws.Search("_nguoiKy");

            foreach (Cell c in cells)
            {
                c.Value = nguoiKy;
            }

            lops = await apis.GetLops(hocKy);

            lops.ForEach(async lop =>
            {
                Cell cell = search(ws, $"Lớp: {lop.ten}");
                if (cell != null)
                {
                    tietHocs = await apis.GetTietHocsNgay(hocKy, lop, ngay);
                    TkbNgayLopHelper helper = new TkbNgayLopHelper(ws, lop, tietHocs, ngay, size, cell);
                    helper.setBackground();
                    helper.xep();
                }
            });

            if (true)
            {
                //for(int i = 0; i < lops.Count; i++)
                //{
                //    Lop lop = lops[i];
                //    Cell cell = search(ws, $"Lớp: {lop.ten}");
                //    tietHocs = await apis.GetTietHocsNgay(hocKy, lop, ngay);
                //    TkbNgayLopHelper helper = new TkbNgayLopHelper(ws, lop, tietHocs, ngay, size, cell);
                //    helper.setBackground();
                //    helper.xep();
                //}

                //for(int i = 0; i < 24; i++)
                //{
                //    ws[0, i * 9].Value = "lop";
                //    ws[19, i * 9].Value = "lop";
                //}

                //CellRange range = ws["A:I"];
                //CellRange range2 = ws["J:R"];
                //range2.CopyFrom(range);


                //TkbNgayLopHelper tKB_helper = new TkbNgayLopHelper(wb.Worksheets[0], Lop, tietHocs, ngay, size);
                //tKB_helper.setBackground();
                //tKB_helper.xep();
            }
        }