private void exp_excel(bool print) { try { int be = 3, dong = 5, sodong = ds.Tables[0].Rows.Count + 5, socot = ds.Tables[0].Columns.Count - 2, dongke = sodong - 1; tenfile = ttb.Export_Excel(ds, "bcngay"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(ttb.getIndex(0) + "1", ttb.getIndex(0) + "1").EntireColumn.Delete(Missing.Value); for (int i = 0; i < be; i++) { osheet.get_Range(ttb.getIndex(i) + "1", ttb.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(ttb.getIndex(be) + dong.ToString(), ttb.getIndex(socot + 1) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(ttb.getIndex(0) + "4", ttb.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 1; i < dong; i++) { osheet.Cells[dong - 1, i] = get_ten(i - 1); } orange = osheet.get_Range(ttb.getIndex(0) + "1", ttb.getIndex(socot) + sodong.ToString()); osheet.Cells[dong - 1, dsngay.Tables[0].Rows.Count + 5] = "Cộng"; for (int i = 0; i < dsngay.Tables[0].Rows.Count; i++) { osheet.Cells[dong - 1, i + 5] = " " + dsngay.Tables[0].Rows[i]["ten"].ToString(); } osheet.get_Range(ttb.getIndex(4) + "4", ttb.getIndex(dsngay.Tables[0].Rows.Count + 5) + "4").Orientation = 90; osheet.get_Range(ttb.getIndex(0) + "4", ttb.getIndex(dsngay.Tables[0].Rows.Count + 5) + "4").RowHeight = 30; orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 2] = ttb.Syte; osheet.Cells[2, 2] = ttb.Tenbv; osheet.Cells[1, 4] = "BÁO CÁO SỬ DỤNG"; osheet.Cells[2, 4] = (tu.Text == den.Text)?"Ngày : " + tu.Text:"Từ ngày : " + tu.Text + " đến : " + den.Text; orange = osheet.get_Range(ttb.getIndex(3) + "1", ttb.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { try { ttb.check_process_Excel(); ds = dsxml.Copy(); int be = 2, dong = 4, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong - 1; tenfile = ttb.Export_Excel(ds, "dutru"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(ttb.getIndex(i) + "1", ttb.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(ttb.getIndex(be - 1) + dong.ToString(), ttb.getIndex(socot + 1) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(ttb.getIndex(0) + "3", ttb.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; int pos = 7; foreach (DataRow r in dtmakp.Select("makp<>''", "stt,makp")) { osheet.Cells[dong - 1, pos] = r["tenkp"].ToString(); pos += 1; } //osheet.Cells[dong-1,pos]="Tồn "+makho.Text; for (int i = 0; i < 6; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i); } orange = osheet.get_Range(ttb.getIndex(0) + "1", ttb.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.Cells[1, 2] = ttb.Syte; osheet.Cells[2, 2] = ttb.Tenbv; s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); osheet.Cells[1, 4] = "TỔNG HỢP DÙ TRÙ"; string s_title = ttb.title(tu.Value.ToString(), tu.Value.ToString()) + " năm " + yyyy.Value.ToString(); osheet.Cells[2, 4] = s_title; orange = osheet.get_Range(ttb.getIndex(3) + "1", ttb.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch { } }
private void exp_excel(bool print) { d.check_process_Excel(); ds = dsxml.Copy(); int be = 2, dong = 4, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong - 1; tenfile = d.Export_Excel(ds, "cosotutruc"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(d.getIndex(be - 1) + dong.ToString(), d.getIndex(socot + 1) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(d.getIndex(0) + "3", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i < 8; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i); } orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 2] = d.Syte; osheet.Cells[2, 2] = d.Tenbv; osheet.Cells[1, 4] = "BÁO CÁO SỬ DỤNG NỘI TRÚ"; string s_title = "Từ ngày " + tu.Text + " đến ngày " + den.Text; if (tu.Text == den.Text) { s_title = "Ngày " + tu.Text; } osheet.Cells[2, 4] = s_title; orange = osheet.get_Range(d.getIndex(3) + "1", d.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } }
private void exp_excel(bool print) { d.check_process_Excel(); ds = dsxml.Copy(); int dong = 2, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong - 1; tenfile = d.Export_Excel(ds, "cosotutruc"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(d.getIndex(3) + dong.ToString(), d.getIndex(socot + 1) + sodong.ToString()).NumberFormat = format_soluong; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; int pos = 5; foreach (DataRow r in dtmakp.Select("makp<>''", "stt,makp")) { osheet.Cells[dong - 1, pos] = r["tenkp"].ToString(); pos += 1; } for (int i = 0; i < 4; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i); } orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; string s_title = "Từ ngày " + tu.Text + " đến ngày " + den.Text; if (tu.Text == den.Text) { s_title = "Ngày " + tu.Text; } osheet.PageSetup.LeftHeader = d.Syte + "\n" + d.Tenbv; osheet.PageSetup.CenterHeader = "&\"Arial,Bold\"&14BÁO CÁO CƠ SỐ TỦ TRỰC\n" + s_title; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } }
private void exp_excel(bool print) { d.check_process_Excel(); ds = dsxml.Copy(); int k = 7, dong = 1, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong; tenfile = d.Export_Excel(ds, "BCNHAPKHO"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; //for(int i=0;i<2;i++) osheet.get_Range(d.getIndex(i)+"1",d.getIndex(i)+"1").EntireRow.Insert(Missing.Value); osheet.get_Range(d.getIndex(1) + dong.ToString(), d.getIndex(socot + 1) + sodong.ToString()).NumberFormat = format_soluong; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i < 6; i++) { osheet.Cells[dong, i + 1] = get_ten(i); } for (int j = Convert.ToInt16(tu.Value); j <= Convert.ToInt16(den.Value); j++) { osheet.Cells[dong, k++] = "Tháng " + j.ToString().PadLeft(2, '0'); } osheet.Cells[dong, k] = "Tổng cộng"; orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; string s_title = "Từ tháng " + tu.Value.ToString().PadLeft(2, '0') + " đến " + den.Value.ToString().PadLeft(2, '0'); if (tu.Text == den.Text) { s_title = "Tháng " + tu.Value.ToString().PadLeft(2, '0'); } s_title += " Năm " + yyyy.Value.ToString(); osheet.PageSetup.LeftHeader = d.Syte + "\n" + d.Tenbv; osheet.PageSetup.CenterHeader = "&\"Arial,Bold\"&14BÁO CÁO NHẬP KHO\n" + s_title; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } }
private void exp_excel(bool print) { d.check_process_Excel(); ds = dsxml.Copy(); int dong = 2, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong - 1; tenfile = d.Export_Excel(ds, "sudung"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; //for(int i=0;i<be;i++) osheet.get_Range(d.getIndex(i)+"1",d.getIndex(i)+"1").EntireRow.Insert(Missing.Value); osheet.get_Range(d.getIndex(3) + dong.ToString(), d.getIndex(socot + 1) + sodong.ToString()).NumberFormat = format_soluong; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; int pos = 5, colfix = 4; if (bGia) { pos = 6; colfix = 5; } foreach (DataRow r in dtmakp.Select("", "stt,makp")) { osheet.Cells[dong - 1, pos] = r["tenkp"].ToString(); pos += 1; } for (int i = 0; i < colfix; i++) { osheet.Cells[dong - 1, i + 1] = (bGia) ? get_ten_gia(i) : get_ten(i); } // orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; // osheet.Cells[1,2]=d.Syte;osheet.Cells[2,2]=d.Tenbv; // osheet.Cells[1,4]="BÁO CÁO SỬ DỤNG NỘI TRÚ"; // osheet.Cells[2,4]=s_title; string s_title = "Từ ngày " + tu.Text + " đến ngày " + den.Text; if (tu.Text == den.Text) { s_title = "Ngày " + tu.Text; } osheet.PageSetup.LeftHeader = d.Syte + "\n" + d.Tenbv; osheet.PageSetup.CenterHeader = "&\"Arial,Bold\"&14BÁO CÁO SỬ DỤNG NỘI TRÚ\n" + s_title; // orange=osheet.get_Range(d.getIndex(3)+"1",d.getIndex(socot-1)+"2"); // orange.HorizontalAlignment=XlHAlign.xlHAlignCenterAcrossSelection; // orange.Font.Size=12; // orange.Font.Bold=true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } }
private void exp_excel(bool print) { try { d.check_process_Excel(); int i_rec = 0, be = 4, dong = 6, sodong = ads.Tables[0].Rows.Count + 6, socot = ads.Tables[0].Columns.Count - 1, dongke = sodong - 1; char[] cSplit = { '+' }; string[] sTitle = haison.Split(cSplit); i_rec = sTitle.Length; tenfile = d.Export_Excel(ads, "HOSOBENHAN"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(d.getIndex(0) + "5", d.getIndex(0) + "5").EntireRow.Delete(Missing.Value); //remove row field osheet.get_Range(d.getIndex(0) + "4", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i < i_rec; i++) { osheet.Cells[dong - 2, i + 1] = sTitle[i].ToString(); } orange = osheet.get_Range(d.getIndex(i_rec * 2 + 4) + "4", d.getIndex(i_rec * 2 + 5) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; // osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; // osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; // osheet.PageSetup.LeftMargin = 20; // osheet.PageSetup.RightMargin = 20; // osheet.PageSetup.TopMargin = 30; // osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 1] = d.Syte; osheet.Cells[2, 1] = d.Tenbv; orange = osheet.get_Range(d.getIndex(1) + "1", d.getIndex(3) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; osheet.Cells[1, 8] = "SỔ VÀO VIỆN - RA VIỆN - CHUYỂN VIỆN"; osheet.Cells[2, 8] = (tu.Text == den.Text) ? "Tháng " + tu.Text : "Từ ngày " + tu.Text + " đến ngày" + den.Text; if (s_tenkp.Trim().Trim(',') != "") { osheet.Cells[3, 8] = s_tenkp; } orange = osheet.get_Range(d.getIndex(3) + "1", d.getIndex(socot - 1) + "3"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void exp_excel(bool print) { try { string loai = loaibenh.Text != ""?"(" + loaibenh.Text.ToUpper() + ")":""; int be = 5, dong = 4, sodong = ds.Tables[0].Rows.Count + 1, socot = ds.Tables[0].Columns.Count + 1, dongke = sodong - 1; tenfile = m.Export_Excel(ds, "bcngay"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(b.getIndex(0) + "1", b.getIndex(0) + "1").EntireRow.Delete(Missing.Value); for (int i = 0; i < be; i++) { osheet.get_Range(b.getIndex(i) + "1", b.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(b.getIndex(1) + dong.ToString(), b.getIndex(socot - 2) + (dong + sodong + 1).ToString()).NumberFormat = "#,##"; osheet.get_Range(b.getIndex(0) + dong.ToString(), b.getIndex(socot - 2) + (dong + dongke + 1).ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; osheet.get_Range(b.getIndex(0) + (dong + 1), b.getIndex(0) + dong).Merge(Missing.Value); osheet.get_Range(b.getIndex(0) + (dong + 1), b.getIndex(0) + dong).VerticalAlignment = XlVAlign.xlVAlignCenter; osheet.get_Range(b.getIndex(1) + dong, b.getIndex(16) + dong).Merge(Missing.Value); osheet.get_Range(b.getIndex(1) + dong, b.getIndex(16) + dong).HorizontalAlignment = XlHAlign.xlHAlignCenter; osheet.get_Range(b.getIndex(17) + dong, b.getIndex(32) + dong).Merge(Missing.Value); osheet.get_Range(b.getIndex(17) + dong, b.getIndex(32) + dong).HorizontalAlignment = XlHAlign.xlHAlignCenter; osheet.get_Range(b.getIndex(33) + dong, b.getIndex(48) + dong).Merge(Missing.Value); osheet.get_Range(b.getIndex(33) + dong, b.getIndex(48) + dong).HorizontalAlignment = XlHAlign.xlHAlignCenter; osheet.get_Range(b.getIndex(49) + (dong + 1), b.getIndex(49) + dong).Merge(Missing.Value); osheet.Cells[dong, 1] = get_tenhead(0); osheet.Cells[dong, 2] = get_tenhead(1); osheet.Cells[dong, 18] = get_tenhead(2); osheet.Cells[dong, 34] = get_tenhead(3); osheet.Cells[dong, 50] = get_tenhead(4); for (int i = 1; i < socot; i++) { osheet.Cells[dong + 1, i] = get_ten(i - 1); } orange = osheet.get_Range(b.getIndex(0) + "1", b.getIndex(socot - 1) + (dong + sodong).ToString()); osheet.get_Range(b.getIndex(1) + (dong + 1), b.getIndex(socot - 3) + (dong + 1)).Orientation = 90; osheet.get_Range(b.getIndex(1) + (dong + 1), b.getIndex(socot - 2) + (dong + 1)).RowHeight = 50; orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 1] = b.Syte; osheet.Cells[2, 1] = b.Tenbv; osheet.Cells[1, 4] = "TÌNH HÌNH BỆNH NHÂN NHẬP XUẤT" + loai; osheet.Cells[2, 4] = (tu.Text == den.Text)?"Ngày : " + tu.Text:"Từ ngày : " + tu.Text + " đến : " + den.Text; orange = osheet.get_Range(b.getIndex(3) + "1", b.getIndex(socot - 1) + "2"); // orange.HorizontalAlignment=XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { d.check_process_Excel(); ds = dsxml.Copy(); int dong = 3, sodong = ds.Tables[0].Rows.Count + dong, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong + 1; tenfile = d.Export_Excel(ds, "BAOCAONXT"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < 2; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(d.getIndex(3) + dong.ToString(), d.getIndex(socot + 1) + sodong.ToString()).NumberFormat = format_soluong; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; int pos = 11; int row = dong - 1; foreach (DataRow r in dtdmkho.Rows) { osheet.Cells[row, pos] = r["ten"].ToString(); osheet.get_Range(d.getIndex(pos - 1) + row.ToString(), d.getIndex(pos) + row.ToString()).HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; pos += 2; } for (int i = 0; i < 10; i++) { osheet.Cells[dong, i + 1] = get_ten(i); if (i < 4) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + dong.ToString()).MergeCells = true; } //else osheet.get_Range(d.getIndex(i)+"1",d.getIndex(i)+"2").MergeCells=true; } for (int i = 8; i < ds.Tables[0].Columns.Count; i++) { osheet.Cells[dong, i + 1] = get_ten((i % 2 == 0)?4:5); } osheet.Cells[dong - 1, 5] = "Tồn đầu"; osheet.Cells[dong - 1, 7] = "Nhập"; osheet.Cells[dong - 1, 9] = "Nhập khác"; osheet.Cells[dong - 2, 11] = "Xuất"; osheet.Cells[dong - 1, 11 + dtdmkho.Rows.Count * 2] = "Tồn cuối"; osheet.get_Range(d.getIndex(10) + "1", d.getIndex(ds.Tables[0].Columns.Count - 3) + "1").HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange = osheet.get_Range(d.getIndex(4) + "1", d.getIndex(5) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.VerticalAlignment = XlVAlign.xlVAlignCenter; orange.MergeCells = true; orange = osheet.get_Range(d.getIndex(6) + "1", d.getIndex(7) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.VerticalAlignment = XlVAlign.xlVAlignCenter; orange.MergeCells = true; orange = osheet.get_Range(d.getIndex(8) + "1", d.getIndex(9) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.VerticalAlignment = XlVAlign.xlVAlignCenter; orange.MergeCells = true; orange = osheet.get_Range(d.getIndex(socot - 1) + "1", d.getIndex(socot) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.VerticalAlignment = XlVAlign.xlVAlignCenter; orange.MergeCells = true; orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; string s_title = "Từ tháng " + tu.Value.ToString().PadLeft(2, '0') + " đến " + den.Value.ToString().PadLeft(2, '0'); if (tu.Text == den.Text) { s_title = "Tháng " + tu.Value.ToString().PadLeft(2, '0'); } s_title += " Năm " + yyyy.Value.ToString(); osheet.PageSetup.LeftHeader = d.Syte + "\n" + d.Tenbv; osheet.PageSetup.CenterHeader = "&\"Arial,Bold\"&14BÁO CÁO NHẬP XUẤT TỒN\n" + s_title; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } }
private void exp_excel_eee(bool print) { try { d.check_process_Excel(); int be = 3, cot = ds.Tables[0].Columns.Count, dong = ds.Tables[0].Rows.Count + be + 2; tenfile = d.Export_Excel(ds, "TONGHOP"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } for (int i = 0; i < 4; i++) { osheet.Cells[be + 1, i + 1] = get_ten(i); } DataRow [] dr = dsmabd.Tables[0].Select("true", "tenbd"); for (int i = 0; i < dr.Length; i++) { osheet.Cells[be + 1, i + 4] = dr[i]["tenbd"].ToString(); osheet.Cells[dong, i + 4] = dr[i]["soluong"].ToString(); } orange = osheet.get_Range(d.getIndex(be) + "4", d.getIndex(cot - 1) + "4"); orange.VerticalAlignment = XlVAlign.xlVAlignBottom; orange.Orientation = 90; orange.RowHeight = 200; orange.EntireRow.AutoFit(); orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(cot - 1) + dong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.Font.Bold = false; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(cot - 1) + dong.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; //orange.EntireRow.AutoFit(); orange.EntireColumn.AutoFit(); osheet.get_Range(d.getIndex(3) + dong.ToString(), d.getIndex(cot - 1) + dong.ToString()).Font.Bold = true; oxl.ActiveWindow.DisplayZeros = false; osheet.Cells[1, 2] = ""; //makp.Text; osheet.Cells[2, 3] = (tu.Text == den.Text)?"Ngày " + tu.Text:"Ngày " + tu.Text + " - " + den.Text; osheet.Cells[1, 3] = "TỔNG HỢP SỬ DỤNG THUỐC"; orange = osheet.get_Range(d.getIndex(2) + "1", d.getIndex(cot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { try { int i_rec = dtdmkho.Rows.Count, be = 4, dong = 6, sodong = ds.Tables[0].Rows.Count + 6, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong - 1; tenfile = d.Export_Excel(ds, "danhap"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(0) + "1").EntireColumn.Delete(Missing.Value); for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(d.getIndex(be) + dong.ToString(), d.getIndex(socot) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(socot - 1) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i < i_rec; i++) { osheet.Cells[dong - 2, i *2 + 5] = dtdmkho.Rows[i]["ten"].ToString(); orange = osheet.get_Range(d.getIndex(i * 2 + 4) + "4", d.getIndex(i * 2 + 5) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; } osheet.Cells[dong - 2, i_rec *2 + 5] = "Tổng cộng"; orange = osheet.get_Range(d.getIndex(i_rec * 2 + 4) + "4", d.getIndex(i_rec * 2 + 5) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; for (int i = 1; i <= be; i++) { osheet.Cells[dong - 1, i] = get_ten(i + 1); orange = osheet.get_Range(d.getIndex(i - 1) + "4", d.getIndex(i - 1) + "5"); orange.MergeCells = true; } for (int i = be; i < socot; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i % 2); } orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 2] = d.Syte; osheet.Cells[2, 2] = d.Tenbv; orange = osheet.get_Range(d.getIndex(1) + "1", d.getIndex(3) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); s_tu = tu.Value.ToString().PadLeft(2, '0'); s_den = den.Value.ToString().PadLeft(2, '0'); s_yy = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); osheet.Cells[1, 4] = "BÁO CÁO LĨNH TỪ " + khott.Text.Trim().ToUpper(); osheet.Cells[2, 4] = (tu.Value == den.Value)?"Tháng : " + s_tu + "/" + yyyy.Value.ToString():"Từ tháng :" + s_tu + "/" + yyyy.Value.ToString() + " đến tháng :" + s_den + "/" + yyyy.Value.ToString(); orange = osheet.get_Range(d.getIndex(3) + "1", d.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { d.check_process_Excel(); try { int be = 3, dong = 5, sodong = dsxml.Tables[0].Rows.Count + 5, socot = dsxml.Tables[0].Columns.Count - 1, dongke = sodong; tenfile = d.Export_Excel(dsxml, "solankham"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));//,Missing.Value,Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); //,Missing.Value); } osheet.get_Range(d.getIndex(be + 2) + dong.ToString(), d.getIndex(socot) + sodong.ToString()).NumberFormat = "#,##0"; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i <= socot; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i).ToString(); } osheet.Cells[sodong, 2] = "TỔNG CỘNG"; orange = osheet.get_Range(d.getIndex(0) + "4", d.getIndex(1) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; int so = sodong; osheet.Cells[sodong, 4] = soluot; osheet.Cells[sodong, 5] = dcongkham; osheet.Cells[sodong, 6] = dthuoc; osheet.Cells[sodong, 7] = dcls; osheet.Cells[sodong, 8] = dcongkham + dthuoc + dcls; orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlPortrait; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.Cells[sodong + 1, 6] = "Ngày ... tháng ... năm ...."; osheet.Cells[sodong + 2, 2] = "THỦ TRƯỞNG ĐƠN VỊ"; osheet.Cells[sodong + 2, 6] = " NGƯỜI LẬP BIỂU "; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 1] = d.Syte; osheet.Cells[2, 1] = d.Tenbv; orange = osheet.get_Range(d.getIndex(1) + "1", d.getIndex(3) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; osheet.Cells[1, 3] = "TỔNG HỢP SỐ LƯỢT KHÁM BỆNH " + madoituong.Text.Trim().ToUpper() + " NGỌAI TRÚ"; osheet.Cells[2, 3] = (tu.Text == den.Text)?"Ngày : " + tu.Text:"Từ ngày :" + tu.Text + " đến ngày :" + den.Text; orange = osheet.get_Range(d.getIndex(2) + "1", d.getIndex(socot) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { try { int be = 3, cot = ds.Tables[0].Columns.Count, dong = ds.Tables[0].Rows.Count + be + 2; tenfile = d.Export_Excel(ds, "ylenh"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } for (int i = 0; i < 5; i++) { osheet.Cells[be + 1, i + 1] = get_ten(i); } DataRow [] dr = dsmabd.Tables[0].Select("true", "stt"); //"tenbd"; for (int i = 0; i < dr.Length; i++) { osheet.Cells[be + 1, i + 6] = dr[i]["tenbd"].ToString(); osheet.Cells[dong, i + 6] = dr[i]["soluong"].ToString(); } //Phong giuong orange = osheet.get_Range(d.getIndex(1) + "4", d.getIndex(2) + "4"); orange.VerticalAlignment = XlVAlign.xlVAlignBottom; orange.Orientation = 90; orange.RowHeight = 180; //Ten Thuoc orange = osheet.get_Range(d.getIndex(be + 2) + "4", d.getIndex(cot - 1) + "4"); orange.VerticalAlignment = XlVAlign.xlVAlignBottom; orange.WrapText = false; orange.Orientation = 90; orange.RowHeight = 180; orange.Font.Bold = true; orange.EntireRow.AutoFit(); //Hien thi chi tiet orange = osheet.get_Range(d.getIndex(0) + "5", d.getIndex(cot - 1) + dong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.Font.Bold = false; orange.RowHeight = 16; orange.NumberFormat = "###0.##"; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(cot) + dong.ToString()).Borders.LineStyle = XlLineStyle.xlDot; // XlBorderWeight.xlThin; orange.EntireColumn.AutoFit(); //cot hoten BN: In dam orange = osheet.get_Range(d.getIndex(4) + "4", d.getIndex(4) + dong.ToString()); orange.Font.Name = "Arial"; orange.Font.Bold = true; orange.EntireColumn.AutoFit(); // string s_tt = (tt1.Checked)?tt1.Text:(tt2.Checked)?tt2.Text:""; osheet.get_Range(d.getIndex(4) + dong.ToString(), d.getIndex(cot - 1) + dong.ToString()).Font.Bold = true; oxl.ActiveWindow.DisplayZeros = false; osheet.Cells[1, 2] = makp.Text + " " + s_tt; osheet.Cells[2, 2] = (tu.Text == den.Text)?"Ngày " + tu.Text:"Ngày " + tu.Text + " - " + den.Text; osheet.Cells[2, 6] = ((s_tenphieu == "")?"":s_tenphieu + " : ") + ((s_buoi == "")?"Cả ngày":s_buoi); osheet.Cells[1, 5] = "TỔNG HỢP Y LỆNH"; orange = osheet.get_Range(d.getIndex((cot > 3)?4:cot - 1) + "1", d.getIndex(cot - 1) + "1"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; //border lai dong cot int jcot = (cot < 16)?16:cot; // for (int ji = 0; ji < jcot; ji++) { orange = osheet.get_Range(m.getIndex(ji) + "4", m.getIndex(ji) + dong); orange.Cells.BorderAround(5, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, 0); if (ji >= cot) { orange.ColumnWidth = 3; //[b.getIndex(0)+"3",b.getIndex(ji)] } } for (int ji = 4; ji < dong; ji++) { orange = osheet.get_Range(m.getIndex(0) + ji, m.getIndex(jcot) + ji); orange.Cells.BorderAround(5, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, 0); } orange = osheet.get_Range(m.getIndex(0) + "4:" + m.getIndex(0) + dong, m.getIndex(0) + "4:" + m.getIndex(jcot) + dong); orange.Cells.BorderAround(1, Excel.XlBorderWeight.xlThin, Excel.XlColorIndex.xlColorIndexAutomatic, 2); // //ke them row trong for (int ji = 0; ji < jcot; ji++) { orange = osheet.get_Range(m.getIndex(ji) + (dong + 3), m.getIndex(ji) + (dong + 15)); orange.Cells.BorderAround(5, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, 0); if (ji >= cot) { orange.ColumnWidth = 3; //[b.getIndex(0)+"3",b.getIndex(ji)] } } for (int ji = dong + 3; ji < dong + 15; ji++) { orange = osheet.get_Range(m.getIndex(0) + ji, m.getIndex(jcot - 1) + ji); orange.Cells.BorderAround(5, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, 0); } // for (int ji = 5; ji <= dong + 15; ji++) { orange = osheet.get_Range(m.getIndex(0) + ji, m.getIndex(cot) + ji); orange.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; orange.RowHeight = 16; orange.WrapText = false; } // //Ten Thuoc orange = osheet.get_Range(d.getIndex(be + 2) + "4", d.getIndex(cot - 1) + "4"); orange.VerticalAlignment = XlVAlign.xlVAlignBottom; orange.WrapText = false; orange.Orientation = 90; orange.RowHeight = 180; orange.Font.Bold = true; orange.EntireRow.AutoFit(); //end binh osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { try { m_v.check_process_Excel(); int i_rec = 0, be = 4, dong = 6, sodong = ads.Tables[0].Rows.Count + 6, socot = ads.Tables[0].Columns.Count - 1, dongke = sodong - 1; char[] cSplit = { '+' }; string[] sTitle = haison.Split(cSplit); i_rec = sTitle.Length; tenfile = m_v.f_export_excel(ads.Tables[0], "doanhthu"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(m_v.getIndex(i) + "1", m_v.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(m_v.getIndex(0) + "5", m_v.getIndex(0) + "5").EntireRow.Delete(Missing.Value);//remove row field osheet.get_Range(m_v.getIndex(2) + "5", m_v.getIndex(socot) + sodong.ToString()).NumberFormat = "###,###,###,###"; osheet.get_Range(m_v.getIndex(0) + "4", m_v.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; osheet.Cells[dong - 2, 1] = "STT"; osheet.Cells[dong - 2, 2] = "Nội dung"; osheet.Cells[dong + 3, 2] = "Tổng cộng"; for (int i = 0; i < i_rec; i++) { osheet.Cells[dong - 2, i + 3] = sTitle[i].ToString(); osheet.Cells[dong + 3, i + 3] = "=SUM(" + m_v.getIndex(i + 2) + "5:" + m_v.getIndex(i + 2) + "8)"; } orange = osheet.get_Range(m_v.getIndex(i_rec * 2 + 4) + "4", m_v.getIndex(i_rec * 2 + 5) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; orange = osheet.get_Range(m_v.getIndex(0) + "1", m_v.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 1] = m_v.Syte; osheet.Cells[2, 1] = m_v.Tenbv; orange = osheet.get_Range(m_v.getIndex(1) + "1", m_v.getIndex(3) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; osheet.Cells[1, 8] = "BÁO CÁO DOANH THU THEO NGƯỜI THU"; osheet.Cells[2, 8] = (tu.Value == den.Value) ? "Ngày " + tu.Text : "Từ ngày :" + tu.Text + " đến ngày :" + den.Text; orange = osheet.get_Range(m_v.getIndex(3) + "1", m_v.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { try { DataSet tmp = new DataSet(); tmp = ds.Copy(); ds.Clear(); ds.Merge(tmp.Tables[0].Select("true", "ten,dang")); int k = 1; foreach (DataRow r in ds.Tables[0].Rows) { r["stt"] = k++; } int be = 5, dong = 7, sodong = ds.Tables[0].Rows.Count + 6, socot = ds.Tables[0].Columns.Count - 1, dongke = sodong; tenfile = d.Export_Excel(ds, "bcngay"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(d.getIndex(0) + "1", d.getIndex(0) + "1").EntireColumn.Delete(Missing.Value); for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(d.getIndex(be) + dong.ToString(), d.getIndex(socot) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(d.getIndex(0) + "5", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 1; i < dong - 2; i++) { osheet.Cells[dong - 1, i] = get_ten(i - 1); } orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot + 7) + (sodong + 7).ToString()); osheet.Cells[dong - 1, dsngay.Tables[0].Rows.Count + 5] = "Tổng cộng"; osheet.Cells[dong - 1, dsngay.Tables[0].Rows.Count + 6] = "Ghi Chú"; for (int i = 0; i < dsngay.Tables[0].Rows.Count; i++) { osheet.Cells[dong - 1, i + 5] = " " + dsngay.Tables[0].Rows[i]["ten"].ToString(); } osheet.get_Range(d.getIndex(4) + "6", d.getIndex(dsngay.Tables[0].Rows.Count + 3) + "6").Orientation = 90; osheet.get_Range(d.getIndex(0) + "6", d.getIndex(dsngay.Tables[0].Rows.Count + 3) + "6").RowHeight = 30; orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 2] = d.Syte; osheet.Cells[2, 2] = d.Tenbv; osheet.Cells[3, 2] = "Khoa: " + makp.Text; osheet.Cells[1, socot] = "MS: 16D/BV-01"; osheet.Cells[2, socot] = "Số:"; orange = osheet.get_Range(osheet.Cells[1, socot], osheet.Cells[2, socot]); orange.Font.Bold = false; orange.HorizontalAlignment = XlHAlign.xlHAlignLeft; orange = osheet.get_Range(osheet.Cells[dong - 1, 1], osheet.Cells[dong - 1, dsngay.Tables[0].Rows.Count + 6]); orange.Font.Bold = true; orange = osheet.get_Range(d.getIndex(1) + "5", d.getIndex(1) + "6"); orange.Merge(Type.Missing); //excelApp.get_Range("A1:A360,B1:E1", Type.Missing).Merge(Type.Missing) orange = osheet.get_Range(d.getIndex(2) + "5", d.getIndex(2) + "6"); orange.Merge(Type.Missing); orange = osheet.get_Range(d.getIndex(3) + "5", d.getIndex(3) + "6"); orange.Merge(Type.Missing); orange = osheet.get_Range(d.getIndex(0) + "5", d.getIndex(0) + "6"); orange.Merge(Type.Missing); orange = osheet.get_Range(d.getIndex(socot) + "5", d.getIndex(socot) + "6"); orange.Merge(Type.Missing); orange = osheet.get_Range(d.getIndex(socot - 1) + "5", d.getIndex(socot - 1) + "6"); orange.Merge(Type.Missing); orange = osheet.get_Range(d.getIndex(4) + "5", d.getIndex(socot - 2) + "5"); orange.Merge(Type.Missing); orange.HorizontalAlignment = XlHAlign.xlHAlignCenter; osheet.Cells[5, 5] = "Ngày"; osheet.get_Range(d.getIndex(0) + "7", d.getIndex(socot) + "7").EntireRow.Insert(Missing.Value); osheet.Cells[7, 1] = "A"; osheet.Cells[7, 2] = "B"; osheet.Cells[7, 3] = "C"; osheet.Cells[7, 4] = "D"; osheet.Cells[7, socot] = "E"; osheet.Cells[7, socot + 1] = "G"; orange = osheet.get_Range(d.getIndex(0) + "7", d.getIndex(socot + 2) + "7"); string s_ngay = d.Ngay_hethong; osheet.Cells[sodong + 3, 2] = "NGƯỜI THỐNG KÊ"; osheet.Cells[sodong + 3, 6] = "KẾ TOÁN DƯỢC"; osheet.Cells[sodong + 3, 19] = "Ngày " + s_ngay.Substring(0, 2) + " tháng " + s_ngay.Substring(3, 2) + " năm " + s_ngay.Substring(6, 4); osheet.Cells[sodong + 4, 19] = "TRƯỞNG KHOA " + makp.Text.ToUpper(); osheet.Cells[sodong + 7, 2] = "Họ tên: "; osheet.Cells[sodong + 7, 6] = "Họ tên: "; osheet.Cells[sodong + 8, 19] = "Họ tên: "; orange = osheet.get_Range(osheet.Cells[sodong + 3, 2], osheet.Cells[sodong + 4, 20]); orange.Font.Bold = true; //orange.HorizontalAlignment = XlHAlign.xlHAlignCenter; orange.Orientation = 0; //osheet.Cells[1,4]="BÁO CÁO SỬ DỤNG"; osheet.Cells[1, 4] = "THỐNG KÊ " + dsngay.Tables[0].Rows.Count.ToString() + " NGÀY SỬ DỤNG THUỐC, HÓA CHẤT,\n VẬT TƯ Y TẾ TIÊU HAO"; osheet.Cells[2, 4] = (tu.Text == den.Text)?"Ngày : " + tu.Text:"Từ ngày : " + tu.Text + " đến : " + den.Text; orange = osheet.get_Range(d.getIndex(3) + "1", d.getIndex(socot - 2) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print) { d.check_process_Excel(); try { int be = 3, dong = 5, sodong = dsxml.Tables[0].Rows.Count + 5, socot = dsxml.Tables[0].Columns.Count - 1, dongke = sodong; tenfile = d.Export_Excel(dsxml, "bccpkcb"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));//,Missing.Value,Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); //,Missing.Value); } osheet.get_Range(d.getIndex(i_cot) + dong.ToString(), d.getIndex(socot) + sodong.ToString()).NumberFormat = "#,##0.00"; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 0; i < i_cot; i++) { osheet.Cells[dong - 1, i + 1] = get_ten(i).ToString(); } osheet.Cells[dong - 1, socot + 1] = "TỔNG CỘNG"; osheet.Cells[sodong, i_cot - 1] = "TỔNG CỘNG"; orange = osheet.get_Range(d.getIndex(0) + "4", d.getIndex(1) + "4"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; int so = sodong, j = 1; decimal tc = 0; foreach (DataRow r in dtnhomvp.Select("true", "stt")) { osheet.Cells[dong - 1, j + i_cot] = r["ten"].ToString(); orange = osheet.get_Range(d.getIndex(j + i_cot) + "3", d.getIndex(j + i_cot) + "3"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Bold = true; osheet.Cells[sodong, j + i_cot] = r["tc"].ToString(); osheet.get_Range(d.getIndex(j + i_cot - 1) + so.ToString(), d.getIndex(j + i_cot - 1) + so.ToString()).Font.Bold = true; tc += decimal.Parse(r["tc"].ToString()); j++; } osheet.Cells[sodong, socot + 1] = tc; osheet.get_Range(d.getIndex(socot) + so.ToString(), d.getIndex(socot) + so.ToString()).Font.Bold = true; orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 1] = d.Syte; osheet.Cells[2, 1] = d.Tenbv; orange = osheet.get_Range(d.getIndex(1) + "1", d.getIndex(3) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; osheet.Cells[1, 3] = "BÁO CÁO CHI PHÍ KHÁM CHỮA BỆNH " + madoituong.Text.Trim().ToUpper() + " NGỌAI TRÚ"; osheet.Cells[2, 3] = (tu.Text == den.Text)?"Ngày : " + tu.Text:"Từ ngày :" + tu.Text + " đến ngày :" + den.Text; orange = osheet.get_Range(d.getIndex(2) + "1", d.getIndex(socot) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excel(bool print, bool biendong) { try { int be = 3, dong = 5, sodong = ds.Tables[0].Rows.Count + 5, socot = ds.Tables[0].Columns.Count - 2, dongke = sodong - 1; tenfile = ttb.Export_Excel(ds, "theodoigia"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; osheet.get_Range(ttb.getIndex(0) + "1", ttb.getIndex(0) + "1").EntireColumn.Delete(Missing.Value); for (int i = 0; i < be; i++) { osheet.get_Range(ttb.getIndex(i) + "1", ttb.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } osheet.get_Range(ttb.getIndex(be) + dong.ToString(), ttb.getIndex(socot + 1) + sodong.ToString()).NumberFormat = "#,##0.000"; osheet.get_Range(ttb.getIndex(0) + "4", ttb.getIndex(socot) + dongke.ToString()).Borders.LineStyle = XlBorderWeight.xlHairline; for (int i = 1; i < dong; i++) { osheet.Cells[dong - 1, i] = get_ten(i - 1); } orange = osheet.get_Range(ttb.getIndex(0) + "1", ttb.getIndex(socot) + sodong.ToString()); orange.Font.Name = "Arial"; orange.Font.Size = 8; orange.EntireColumn.AutoFit(); oxl.ActiveWindow.DisplayZeros = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; osheet.Cells[1, 2] = ttb.Syte; osheet.Cells[2, 2] = ttb.Tenbv; s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); s_tu = tu.Value.ToString().PadLeft(2, '0'); s_den = den.Value.ToString().PadLeft(2, '0'); s_yy = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); osheet.Cells[1, 4] = "THEO DÕI BIẾN ĐỘNG GIÁ"; osheet.Cells[2, 4] = (tu.Value == den.Value && yy.Value == yyyy.Value)?"Tháng : " + s_tu + "/" + yyyy.Value.ToString():"Từ tháng :" + s_tu + "/" + yy.Value.ToString() + " đến tháng :" + s_den + "/" + yyyy.Value.ToString(); orange = osheet.get_Range(ttb.getIndex(3) + "1", ttb.getIndex(socot - 1) + "2"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; osheet.get_Range(ttb.getIndex(4) + "4", ttb.getIndex(ds.Tables[0].Columns.Count) + "4").NumberFormat = "@"; osheet.get_Range(ttb.getIndex(4) + "4", ttb.getIndex(ds.Tables[0].Columns.Count) + "4").RowHeight = 24; if (!biendong) { for (int i = 0; i < dtngay.Rows.Count; i++) { osheet.Cells[dong - 1, i + 5] = dtngay.Rows[i]["ngaydoi"].ToString(); } } else { osheet.Cells[dong - 1, 5] = s_tu + "/" + yy.Value.ToString(); if (s_tu != s_den) { osheet.Cells[dong - 1, 6] = s_den + "/" + yyyy.Value.ToString(); osheet.Cells[dong - 1, 7] = "Chênh lệch"; } } orange = osheet.get_Range(ttb.getIndex(4) + "5", ttb.getIndex(socot + 1) + sodong.ToString()); orange.EntireColumn.AutoFit(); if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exp_excelCanLoc(bool print) { try { d.check_process_Excel(); int be = 3, cot = ds.Tables[0].Columns.Count, dong = ds.Tables[0].Rows.Count + be + 2; DataColumn dc = new DataColumn(); dc.ColumnName = "ghichu"; dc.DataType = Type.GetType("System.String"); ds.Tables[0].Columns.Add(dc); DataRow drstt = ds.Tables[0].NewRow(); for (int i = 0; i < cot + 1; i++) { drstt[i] = i.ToString(); } ds.Tables[0].Rows.InsertAt(drstt, 0); tenfile = d.Export_Excel(ds, "ylenh"); oxl = new Excel.Application(); owb = (Excel._Workbook)(oxl.Workbooks.Open(tenfile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); osheet = (Excel._Worksheet)owb.ActiveSheet; oxl.ActiveWindow.DisplayGridlines = true; for (int i = 0; i < be; i++) { osheet.get_Range(d.getIndex(i) + "1", d.getIndex(i) + "1").EntireRow.Insert(Missing.Value); } for (int i = 0; i < 7; i++) { osheet.Cells[be + 1, i + 1] = get_ten(i); } for (int i = 0; i < dsmabd.Tables[0].Rows.Count; i++) { osheet.Cells[be + 1, i + 8] = dsmabd.Tables[0].Rows[i]["tenbd"].ToString(); osheet.Cells[dong + 1, i + 8] = dsmabd.Tables[0].Rows[i]["soluong"].ToString(); } osheet.Cells[4, cot + 1] = "Ghi chú"; orange = osheet.get_Range(d.getIndex(be) + "4", d.getIndex(cot) + "4"); orange.VerticalAlignment = XlVAlign.xlVAlignBottom; orange.Orientation = 90; orange.RowHeight = 200; orange.EntireRow.AutoFit(); orange = osheet.get_Range(d.getIndex(0) + "1", d.getIndex(cot + 10) + dong + 10); orange.Font.Name = "Arial"; orange.Font.Size = 10; orange.Font.Bold = false; osheet.get_Range(d.getIndex(0) + "4", d.getIndex(cot) + (dong + 1)).Borders.LineStyle = XlBorderWeight.xlHairline; //orange.EntireRow.AutoFit(); orange.EntireColumn.AutoFit(); orange = osheet.get_Range(d.getIndex(cot) + "1", d.getIndex(cot + 100) + dong + 10); orange.Cells.ColumnWidth = 3; //to mau tu cot thu 6 for (int i = 7; i < cot; i++) { if (i % 2 == 0) { orange = osheet.get_Range(d.getIndex(i) + "4", d.getIndex(i) + dong.ToString()); orange.Interior.Color = System.Drawing.Color.Beige.ToArgb(); } } // osheet.get_Range(d.getIndex(4) + (dong + 1), d.getIndex(cot - 1) + (dong + 1)).Font.Bold = true; oxl.ActiveWindow.DisplayZeros = false; osheet.Cells[1, 2] = d.Tenbv; osheet.Cells[2, 2] = (tu.Text == den.Text) ? "Ngày " + tu.Text : "Ngày " + tu.Text + " - " + den.Text; osheet.Cells[1, 4] = "TỔNG HỢP Y LỆNH"; orange = osheet.get_Range(d.getIndex(2) + "1", d.getIndex(cot - 1) + "1"); orange.HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; orange.Font.Size = 12; orange.Font.Bold = true; osheet.Cells[dong + 4, 26] = "In ngày " + System.DateTime.Today.Day.ToString() + " tháng " + System.DateTime.Today.Month.ToString() + " năm " + System.DateTime.Today.Year.ToString(); osheet.Cells[dong + 5, 2] = "Khoa Dược"; osheet.Cells[dong + 5, 7] = "Bác Sĩ"; osheet.Cells[dong + 5, 15] = "Điều dưỡng thực hiện"; osheet.Cells[dong + 5, 26] = "Người sao y lệnh"; osheet.Cells[dong + 8, 2] = "Họ tên..................."; osheet.Cells[dong + 8, 7] = "Họ tên..................."; osheet.Cells[dong + 8, 15] = "Họ tên..................."; osheet.Cells[dong + 8, 26] = "Họ tên..................."; //orange = osheet.get_Range(d.getIndex(0) + dong+4, d.getIndex(cot) + dong+4); //orange.Font.Name = "Arial"; //orange.Font.Size = 8; //orange.Font.Bold = false; osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape; osheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4; osheet.PageSetup.LeftMargin = 20; osheet.PageSetup.RightMargin = 20; osheet.PageSetup.TopMargin = 30; osheet.PageSetup.CenterFooter = "Trang : &P/&N"; if (print) { osheet.PrintOut(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } //osheet.PrintPreview(Missing.Value); else { oxl.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }