Exemple #1
0
        private void butExcel_Click(object sender, System.EventArgs e)
        {
            d.check_process_Excel();
            string tenfile = (b_baohiem)?d.Export_Excel(dt, ReportFile.Substring(0, ReportFile.Length - 4)):d.Export_Excel(ds, ReportFile.Substring(0, ReportFile.Length - 4));

            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;
            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";
            oxl.Visible = true;
        }