예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();
            //app.DisplayAlerts = false;
            Workbook   book   = app.Workbooks.Add();
            Worksheets sheets = book.Worksheets.get_Worksheets();
            Worksheet  sheet  = sheets.AddWorksheet();


            sheet = sheets[2];
            sheet.Cells[1, 1].Value2   = app.InchesToPoints2(1.3).ToString();
            sheet.PageSetup.LeftMargin = app.InchesToPoints2(1.3);

            sheet.Cells[2, 2].FormulaR1C1              = "4,1";
            sheet.get_Range("A1", "D3").Font.Size      = 20;
            sheet.get_Range("A1", "D3").Font.Name      = "宋体";
            sheet.get_Range("A1", "D3").Font.Underline = ReflectOffice.Excel.XlUnderlineStyle.xlUnderlineStyleSingle;
            sheet.get_Range("A1", "D3").Font.FontStyle = "加粗 倾斜";
            sheet.get_Range("A1", "D3").ColumnWidth    = 19;
            sheet.get_Range("A1", "D3").RowHeight      = 15;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].Weight    = ReflectOffice.Excel.XlBorderWeight.xlThick;
            sheet.get_Range("A1", "D3").HorizontalAlignment = ReflectOffice.Excel.XlHAlign.xlHAlignCenter;
            sheet.get_Range("A1", "D3").VerticalAlignment   = ReflectOffice.Excel.XlVAlign.xlVAlignCenter;
            sheet.get_Range("A1", "D3").Rows.AutoFit();
            sheet.get_Range("A1", "D3").Columns.AutoFit();

            book.SaveAs(@"r:\abc.xls", XlFileFormat.xlExcel8);
            book.Close();
            app.Release();

            //Microsoft.Office.Interop.Excel.XlUnderlineStyle;
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MSOffice.Application App = new MSOffice.Application();
            //MSOffice.Workbook Book = App.Workbooks.Add(MSOffice.XlWBATemplate.xlWBATWorksheet);
            ReflectOffice.Excel.Application App  = new ReflectOffice.Excel.Application();
            ReflectOffice.Excel.Workbook    book = App.Workbooks.Add();

            App.Visible = true;
        }
예제 #3
0
        //My excel
        private void button5_Click(object sender, EventArgs e)
        {
            string _strFileName = @"r:\abcd.xlsx";

            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();
            //app.Visible = true;

            textBox1.Text     = app.InchesToPoints(5).ToString();
            app.DisplayAlerts = false;
            app.Visible       = false;
            Workbook book = app.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            //Worksheet sheet = new Worksheet(book.Worksheets.Add());
            Worksheet sheet = app.ActiveSheet;

            sheet.Cells[1, 1].Value2   = app.InchesToPoints2(1.3).ToString();
            sheet.PageSetup.LeftMargin = app.InchesToPoints2(1.3);

            sheet.Cells[2, 3].FormulaR1C1              = "4,1";
            sheet.get_Range("A1", "D3").Font.Size      = 20;
            sheet.get_Range("A1", "D3").Font.Name      = "宋体";
            sheet.get_Range("A1", "D3").Font.Underline = ReflectOffice.Excel.XlUnderlineStyle.xlUnderlineStyleSingle;
            sheet.get_Range("A1", "D3").Font.FontStyle = "加粗 倾斜";
            sheet.get_Range("A1", "D3").ColumnWidth    = 19;
            sheet.get_Range("A1", "D3").RowHeight      = 15;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].Weight    = ReflectOffice.Excel.XlBorderWeight.xlThick;
            sheet.get_Range("A1", "D3").HorizontalAlignment = ReflectOffice.Excel.XlHAlign.xlHAlignCenter;
            sheet.get_Range("A1", "D3").VerticalAlignment   = ReflectOffice.Excel.XlVAlign.xlVAlignCenter;
            sheet.get_Range("A1", "D3").Rows.AutoFit();
            sheet.get_Range("A1", "D3").Columns.AutoFit();
            sheet.get_Range("A1", "D3").Merge();
            sheet.Select();

            sheet.get_Range(sheet.Cells[5, 5], sheet.Cells[6, 6]).ColumnWidth = 50;

            sheet.get_Range("A1:E5").CopyPicture();
            sheet.get_Range("A1").CopyPicture();


            Range rng = sheet.get_Range("A11", "D13");

            rng.Merge();

            app.Windows[1].Zoom = 110;


            app.Visible = true;


            //book.SaveAs(_strFileName);
            //app.Release();
        }
예제 #4
0
        private void 新功能测试_Click(object sender, EventArgs e)
        {
            string strTemplatesFile = @"‪D:\a.txt";

            if (!System.IO.File.Exists(strTemplatesFile))
            {
                MessageBox.Show("Excel文件不存在!");
                return;
            }

            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();

            app.Visible       = true;
            app.DisplayAlerts = false;
            //app.Visible = false;
            Workbook tmpBook = app.Workbooks.Open(Filename: strTemplatesFile, ReadOnly: true);
            Workbook book    = app.Workbooks.Add();


            tmpBook.Sheets.get_Worksheets()[1].Copy(book.Sheets.get_Worksheets()[1]);
            tmpBook.Close();

            app.Visible = true;
        }
예제 #5
0
        private void 新功能测试_Click(object sender, EventArgs e)
        {
            string strTemplatesFile = @"E:\Project\SunlikeERP\ERP实施\ERP相关开发\ERP外挂小工具\ERP外挂小工具\bin\Release\ExcelTemplates\tmpltsRequisition.xls";
            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();

            Workbook tmpBook = app.Workbooks.Open(Filename: strTemplatesFile, ReadOnly: true);
            Workbook book = app.Workbooks.Add();

            tmpBook.Sheets.get_Worksheets()[1].Copy(book.Sheets.get_Worksheets()[1]);
            tmpBook.Close();

            app.Visible = true;
        }
예제 #6
0
        //My excel
        private void button5_Click(object sender, EventArgs e)
        {
            string _strFileName = @"r:\abcd.xlsx";

            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();
            //app.Visible = true;

            textBox1.Text = app.InchesToPoints(5).ToString();
            app.DisplayAlerts = false;
            app.Visible = false;
            Workbook book = app.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            //Worksheet sheet = new Worksheet(book.Worksheets.Add());
            Worksheet sheet = app.ActiveSheet;
            sheet.Cells[1, 1].Value2 = app.InchesToPoints2(1.3).ToString();
            sheet.PageSetup.LeftMargin = app.InchesToPoints2(1.3);

            sheet.Cells[2, 3].FormulaR1C1 = "4,1";
            sheet.get_Range("A1", "D3").Font.Size = 20;
            sheet.get_Range("A1", "D3").Font.Name = "宋体";
            sheet.get_Range("A1", "D3").Font.Underline = ReflectOffice.Excel.XlUnderlineStyle.xlUnderlineStyleSingle;
            sheet.get_Range("A1", "D3").Font.FontStyle = "加粗 倾斜";
            sheet.get_Range("A1", "D3").ColumnWidth = 19;
            sheet.get_Range("A1", "D3").RowHeight = 15;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].Weight = ReflectOffice.Excel.XlBorderWeight.xlThick;
            sheet.get_Range("A1", "D3").HorizontalAlignment = ReflectOffice.Excel.XlHAlign.xlHAlignCenter;
            sheet.get_Range("A1", "D3").VerticalAlignment = ReflectOffice.Excel.XlVAlign.xlVAlignCenter;
            sheet.get_Range("A1", "D3").Rows.AutoFit();
            sheet.get_Range("A1", "D3").Columns.AutoFit();
            sheet.get_Range("A1", "D3").Merge();
            sheet.Select();

            sheet.get_Range(sheet.Cells[5, 5], sheet.Cells[6, 6]).ColumnWidth = 50;

            sheet.get_Range("A1:E5").CopyPicture();
            sheet.get_Range("A1").CopyPicture();

            Range rng = sheet.get_Range("A11", "D13");
            rng.Merge();

            app.Windows[1].Zoom = 110;

            app.Visible = true;

            //book.SaveAs(_strFileName);
            //app.Release();
        }
예제 #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            ReflectOffice.Excel.Application app = new ReflectOffice.Excel.Application();
            //app.DisplayAlerts = false;
            Workbook book = app.Workbooks.Add();
            Worksheets sheets = book.Worksheets.get_Worksheets();
            Worksheet sheet = sheets.AddWorksheet();

            sheet = sheets[2];
            sheet.Cells[1, 1].Value2 = app.InchesToPoints2(1.3).ToString();
            sheet.PageSetup.LeftMargin = app.InchesToPoints2(1.3);

            sheet.Cells[2, 2].FormulaR1C1 = "4,1";
            sheet.get_Range("A1", "D3").Font.Size = 20;
            sheet.get_Range("A1", "D3").Font.Name = "宋体";
            sheet.get_Range("A1", "D3").Font.Underline = ReflectOffice.Excel.XlUnderlineStyle.xlUnderlineStyleSingle;
            sheet.get_Range("A1", "D3").Font.FontStyle = "加粗 倾斜";
            sheet.get_Range("A1", "D3").ColumnWidth = 19;
            sheet.get_Range("A1", "D3").RowHeight = 15;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
            sheet.get_Range("A1", "D3").Borders[XlBordersIndex.xlEdgeBottom].Weight = ReflectOffice.Excel.XlBorderWeight.xlThick;
            sheet.get_Range("A1", "D3").HorizontalAlignment = ReflectOffice.Excel.XlHAlign.xlHAlignCenter;
            sheet.get_Range("A1", "D3").VerticalAlignment = ReflectOffice.Excel.XlVAlign.xlVAlignCenter;
            sheet.get_Range("A1", "D3").Rows.AutoFit();
            sheet.get_Range("A1", "D3").Columns.AutoFit();

            book.SaveAs(@"r:\abc.xls", XlFileFormat.xlExcel8);
            book.Close();
            app.Release();

            //Microsoft.Office.Interop.Excel.XlUnderlineStyle;
        }
예제 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MSOffice.Application App = new MSOffice.Application();
            //MSOffice.Workbook Book = App.Workbooks.Add(MSOffice.XlWBATemplate.xlWBATWorksheet);
            ReflectOffice.Excel.Application App = new ReflectOffice.Excel.Application();
            ReflectOffice.Excel.Workbook book = App.Workbooks.Add();

            App.Visible = true;
        }