当前位置: 首页>>代码示例>>C#>>正文


C# Range.Merge方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Excel.Range.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Merge方法的具体用法?C# Range.Merge怎么用?C# Range.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Excel.Range的用法示例。


在下文中一共展示了Range.Merge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InputInformationFields

        /// <summary>
        /// Заповнюємо інформаційні поля
        /// </summary>
        private void InputInformationFields(decimal moneyAtStart, decimal moneyBalance)
        {
            // Кількість грошей, що залишилася:
            oCells = oSheet.Range["E5", "F5"];
            oCells.Merge(Type.Missing);
            oCells.Value = moneyAtStart;
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            // Кількість грошей, що залишилася:
            oCells = oSheet.Range["E20", "F20"];
            oCells.Merge(Type.Missing);
            oCells.Value = moneyBalance;
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;
        }
开发者ID:franko-vv,项目名称:Input-and-Outlay,代码行数:23,代码来源:CreateExcelFile.cs

示例2: InputDataToTemplateExcelFile

        /// <summary>
        /// Створюємо шаблон Excel файла
        /// </summary>
        /// TODO: Винести однотипні styles
        private void InputDataToTemplateExcelFile()
        {
            Excel.Style style = oBook.Styles.Add("newStyle");
            style.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            style.Borders.Weight = Excel.XlBorderWeight.xlThick;
            style.Font.Size = 12;
            style.Font.Bold = true;

            string selectedDate = dateForFileName + " " + yearInput;

            // ---------------------------------ШАПКА-------------------------------------------------
            // Звіт про використання коштів
            oCells = oSheet.Range["A2", "H2"];
            oCells.Merge(Type.Missing);
            oCells.Value = "Звіт про використання коштів " + selectedDate + " р.";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 16;
            oCells.Font.Bold = true;

            // салон Двері Білорусії м.Вінниця
            oCells = oSheet.Range["A3", "H3"];
            oCells.Merge(Type.Missing);
            oCells.Value = "салон Двері Білорусії м.Вінниця";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            // ---------------------------------ГРОШІ В КАЗНІ-------------------------------------------------
            // Залишок на початок дня:
            oCells = oSheet.Range["A5", "D5"];
            oCells.Merge(Type.Missing);
            oCells.Value = "Залишок на початок дня: ";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            oCells = oSheet.Range["G5"];
            oCells.Merge(Type.Missing);
            oCells.Value = "грн.";
            oCells.HorizontalAlignment = Excel.Constants.xlLeft;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            // ---------------------------------ТАБЛИЦЯ-------------------------------------------------
            // Приход:
            oCells = oSheet.Range["A7", "D7"];
            oCells.Merge(Type.Missing);
            oCells.Value = "Приход";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            style.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            style.Borders.Weight = Excel.XlBorderWeight.xlThick;
            style.Font.Size = 12;
            style.Font.Bold = true;

            // Видатки:
            oCells = oSheet.Range["E7", "H7"];
            oCells.Merge(Type.Missing);
            oCells.Value = "Видатки";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            style.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            style.Borders.Weight = Excel.XlBorderWeight.xlThick;
            style.Font.Size = 12;
            style.Font.Bold = true;

            // ---------------------------------ШАПКА ТАБЛИЦІ-------------------------------------------------
            // Сума:
            oCells = oSheet.Range["A8"];
            oCells.Value = "Сума";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            oCells.Borders.Weight = Excel.XlBorderWeight.xlThin;
            oCells.EntireColumn.AutoFit();                              // Автоподбор ширины
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            // Від кого поступили:
            oCells = oSheet.Range["B8"];
            oCells.Merge(Type.Missing);
            oCells.Value = "Від кого поступили";
            oCells.HorizontalAlignment = Excel.Constants.xlCenter;
            oCells.VerticalAlignment = Excel.Constants.xlCenter;
            oCells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            oCells.Borders.Weight = Excel.XlBorderWeight.xlThin;
            oCells.EntireColumn.AutoFit();                              // Автоподбор ширины
            oCells.EntireColumn.WrapText = true;                        // Перенос по словам
            oCells.Font.Size = 12;
            oCells.Font.Bold = true;

            // Хто отримав
//.........这里部分代码省略.........
开发者ID:franko-vv,项目名称:Input-and-Outlay,代码行数:101,代码来源:CreateExcelFile.cs

示例3: createHeaders

        public void createHeaders(int row, int col, string htext, string cell1,
        string cell2, int mergeColumns, string color, bool font, int size, string
        fcolor)
        {
            worksheet.Cells[row, col] = htext;
            workSheet_range = worksheet.get_Range(cell1, cell2);
            workSheet_range.Merge(mergeColumns);

            switch (color)
            {
                case "YELLOW":
                    workSheet_range.Interior.Color = System.Drawing.Color.Yellow.ToArgb();
                    break;
                case "GRAY":
                    workSheet_range.Interior.Color = System.Drawing.Color.Gray.ToArgb();
                    break;
                case "GAINSBORO":
                    workSheet_range.Interior.Color =
            System.Drawing.Color.Gainsboro.ToArgb();
                    break;
                case "Turquoise":
                    workSheet_range.Interior.Color =
            System.Drawing.Color.Turquoise.ToArgb();
                    break;
                case "PeachPuff":
                    workSheet_range.Interior.Color =
            System.Drawing.Color.PeachPuff.ToArgb();
                    break;
                default:
                    //workSheet_range.Interior.Color = System.Drawing.Color.White.ToArgb();
                    break;
            }

            workSheet_range.Borders.Color = System.Drawing.Color.Black.ToArgb();
            workSheet_range.Font.Bold = font;
            workSheet_range.ColumnWidth = size;
            if (fcolor.Equals(""))
            {
                workSheet_range.Font.Color = System.Drawing.Color.White.ToArgb();
            }
            else
            {
                workSheet_range.Font.Color = System.Drawing.Color.Black.ToArgb();
            }
        }
开发者ID:secgoat,项目名称:Dashboards,代码行数:45,代码来源:CreateExcelDoc.cs

示例4: InsertData

        /// <summary>
        /// 向当前活动表插入数据
        /// </summary>
        /// <param name="be"></param>
        public void InsertData(ExcelBE be)
        {
#if IS_USE_EXCEL_COM
            worksheet.Cells[be.Row, be.Col] = be.Text;
            workSheet_range = worksheet.get_Range(be.StartCell, be.EndCell);
            workSheet_range.Merge(be.IsMerge);
            workSheet_range.Interior.Color = GetColorValue(be.InteriorColor);
            workSheet_range.Borders.Color = System.Drawing.Color.Black.ToArgb();
            workSheet_range.ColumnWidth = be.ColumnWidth;
            workSheet_range.RowHeight = be.RowHeight;
            //to-do:枚举HorizontalAlignment
            if (be.HorizontalAlignmentIndex == 1)
            {
                workSheet_range.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; ;
            }
            else if (be.HorizontalAlignmentIndex == 2)
            {
                workSheet_range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; ;
            }
            //to-do:设置单元格边框(未列在参数)
            workSheet_range.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            workSheet_range.Borders.Color = System.Drawing.Color.White.ToArgb();

            workSheet_range.Font.Color = string.IsNullOrEmpty(be.FontColor) ? System.Drawing.Color.White.ToArgb() : System.Drawing.Color.Black.ToArgb();
            workSheet_range.Font.Name = be.FontName;
            workSheet_range.Font.Bold = be.FontBold;
            workSheet_range.Font.Size = be.FontSize;
            workSheet_range.NumberFormat = be.Formart;
#endif
        }
开发者ID:skygreen2001,项目名称:Betterlife.Net,代码行数:34,代码来源:UtilExcelCom.cs

示例5: btnExcel_Click

        private void btnExcel_Click(object sender, EventArgs e)
        {
            if ( !timer1.Enabled )
                btnStart_Click(sender, e);
               object misValue = System.Reflection.Missing.Value;
                xlApp = new Excel.Application();
                xlApp.Visible = false;
                xlWorkBook = xlApp.Workbooks.Add(misValue);
                xlFunction = xlApp.WorksheetFunction;

                xlWorkSheetData = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                xlWorkSheetData.Name = "Pendulum";
                xlWorkSheetData.Activate();

                xlWorkSheetData.Cells[1, 1] = "Constants used, mass: " + tbm.Text + ", gravity: " + tbG.Text + ", Spring Constant: " + tbk.Text + ", Length: " + tbH.Text;
                xlRng = xlWorkSheetData.get_Range("A1", "N1");
                xlRng.Select();
                xlRng.Merge();

                xlWorkSheetData.Cells[2, 1] = "Initial Values used, Intial X: " + tbXi.Text + ", Initial Y: " + tbYi.Text + ", Initial X Velocity: " + vx0.Text + ", Initial Y Velocity: " + vy0.Text;
                xlRng = xlWorkSheetData.get_Range("A2", "N2");
                xlRng.Select();
                xlRng.Merge();

                xlWorkSheetData.Cells[lastRowExcel, 1] = "t"; // changes these to whatever you want
                xlWorkSheetData.Cells[lastRowExcel, 2] = "X";
                xlWorkSheetData.Cells[lastRowExcel, 3] = "Y";
                xlWorkSheetData.Cells[lastRowExcel, 4] = "Vx";
                xlWorkSheetData.Cells[lastRowExcel, 5] = "Vy";
                lblTransfer.Visible = true;
                for (int i = 0; i < excelData.Count; i++)
                {
                    xlWorkSheetData.Cells[i + 4, 1] = (excelData[i].time / 1000.00).ToString();
                    xlWorkSheetData.Cells[i + 4, 2] = excelData[i].x.ToString();
                    xlWorkSheetData.Cells[i + 4, 3] = excelData[i].y.ToString();
                    xlWorkSheetData.Cells[i + 4, 4] = excelData[i].vx.ToString();
                    xlWorkSheetData.Cells[i + 4, 5] = excelData[i].vy.ToString();
                }
                lblTransfer.Visible = false;
                try //essaye le sauvegarde
                {

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        //sauvegarde le classeur courant
                        xlWorkBook.SaveAs(saveFileDialog1.FileName,
                            Excel.XlFileFormat.xlWorkbookDefault, misValue,
                            misValue, misValue, misValue,
                            Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue,
                            misValue, misValue, misValue);
                        xlWorkBook.Close();
                    }

                }
                catch //en cas d'erreur affiche le message
                {
                    MessageBox.Show("Impossible de sauvegarder le fichier.", "Erreur de sauvegarde de fichier Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
        }
开发者ID:harley1011,项目名称:Physics_Simulations-Winforms,代码行数:59,代码来源:Form1.cs


注:本文中的Microsoft.Office.Interop.Excel.Range.Merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。