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


C# Microsoft.get_Range方法代码示例

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


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

示例1: SetColor

 /// <summary>
 /// 设置整个连续区域的字体颜色
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 /// <param name="clrColor">颜色</param>
 public void SetColor(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, System.Drawing.Color clrColor)
 {
     CurSheet.get_Range(objStartCell, objEndCell).Font.Color = System.Drawing.ColorTranslator.ToOle(clrColor);
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs

示例2: CreateColumnName

        public static void CreateColumnName(DataTable dt, Microsoft.Office.Interop.Excel._Worksheet xlSheet, int pos_row)
        {
            int _ColumnsCount = dt.Columns.Count;
            //set thuoc tinh cho cac header
            Microsoft.Office.Interop.Excel.Range header = xlSheet.get_Range("A" + pos_row.ToString(), Convert.ToChar(_ColumnsCount + 65) + pos_row.ToString());
            header.Select();

            header.HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
            header.Font.Bold = true;
            header.Font.Size = 12;

            for (int i = 0; i < dt.Columns.Count; i++)
                xlSheet.Cells[pos_row, i + 1] = dt.Columns[i].ColumnName;
        }
开发者ID:tayeumi,项目名称:HFC,代码行数:14,代码来源:ExportDataToExcel.cs

示例3: setCellValue

        public void setCellValue(System.Collections.ArrayList value, Microsoft.Office.Interop.Excel.Worksheet wsheet, int rowindex, int colum, int count)
        {
            if (value.Count > 0)
            {
                string[,] strs = new string[value.Count, ((ArrayList)value[0]).Count];
                for (int i = 0; i < value.Count; i++)
                    for (int j = 0; j < ((ArrayList)value[i]).Count; j++)
                    {

                        strs[i, j] = (((ArrayList)value[i])[j]).ToString() == "0" ? "" : (((ArrayList)value[i])[j]).ToString();
                    }
                wsheet.get_Range(wsheet.Cells[rowindex, colum], wsheet.Cells[value.Count + rowindex - 1, ((ArrayList)value[0]).Count + colum - 1]).Value2 = strs;
            }
        }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:14,代码来源:ExcelFromArrayList.cs

示例4: return

        TryGetNamedRange
        (
            Microsoft.Office.Interop.Excel.Worksheet worksheet,
            String rangeName,
            out Range namedRange
        )
        {
            Debug.Assert(worksheet != null);
            Debug.Assert(!String.IsNullOrEmpty(rangeName));

            namedRange = null;

            try
            {
                namedRange = worksheet.get_Range(rangeName, Missing.Value);

                return (true);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                return (false);
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:23,代码来源:ExcelUtil.cs

示例5: AddTableToWorksheet

        public void AddTableToWorksheet(DataTable data, Microsoft.Office.Interop.Excel.Worksheet xlsWorksheet)
        {
            // Add columns
            int iCol = 0;
            foreach (DataColumn c in data.Columns)
            {
                iCol++;
                xlsWorksheet.Cells[1, iCol] = c.ColumnName;
            }

            // Add rows
            int iRow = 0;
            foreach (DataRow r in data.Rows)
            {
                iRow++;

                for (int i = 1; i < data.Columns.Count + 1; i++)
                {
                    if (iRow == 1)
                    {
                        // Add the header the first time through 
                        xlsWorksheet.Cells[iRow, i] = data.Columns[i - 1].ColumnName;
                    }

                    if (r[1].ToString() != "")
                    {
                        xlsWorksheet.Cells[iRow + 1, i] = r[i - 1].ToString();
                    }
                }
            }

            var last = xlsWorksheet.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
            var range = xlsWorksheet.get_Range("A1", last);
            range.Columns.AutoFit();
        }
开发者ID:ericjohnolson,项目名称:NadaNtd,代码行数:35,代码来源:ImporterBase.cs

示例6: WriteArrayRoadPavenment

 /// <summary>
 /// Write array to the worksheet Excel
 /// </summary>
 /// <param name="rows">The required amount of row into the worksheet </param>
 /// <param name="columns">The required amount of columns into the worksheet </param>
 /// <param name="worksheet">The worksheet in which data will be written </param>
 /// <param name="data"> The data to be written on the worksheet </param>
 private void WriteArrayRoadPavenment(int rows, int columns, Microsoft.Office.Interop.Excel.Worksheet worksheet, object[,] data)
 {
     var startRow = HEADERROWSRoadPavenment;
     var startCell = worksheet.Cells[startRow + 1, 1] as Microsoft.Office.Interop.Excel.Range; // At excel range start at the 1,1 not the 0,0
     var endCell = worksheet.Cells[rows + startRow, columns] as Microsoft.Office.Interop.Excel.Range;
     var writeRange = worksheet.get_Range(startCell, endCell);
     writeRange.Value2 = data;
 }
开发者ID:Lufan,项目名称:Genplan2012,代码行数:15,代码来源:RoadPavenment.cs

示例7: spreadsheetDataSetTemplate

        private void spreadsheetDataSetTemplate(Microsoft.Office.Interop.Excel.Worksheet worksheet, string astrMethodName)
        {
            if(null != worksheet)
            {
                Microsoft.Office.Interop.Excel.Range rangeMethod = worksheet.get_Range("A1");
                Microsoft.Office.Interop.Excel.Range rangeMethodName = worksheet.get_Range("B1");
                Microsoft.Office.Interop.Excel.Range rangeErrors = worksheet.get_Range("A2");
                Microsoft.Office.Interop.Excel.Range rangeStart = worksheet.get_Range("A3");
                Microsoft.Office.Interop.Excel.Range rangeEnd = worksheet.get_Range("C3");
                Microsoft.Office.Interop.Excel.Range rangeDuraction = worksheet.get_Range("E3");

                rangeMethod.Value2 = "Method";
                rangeMethod.Font.Bold = true;
                rangeMethodName.Value2 = astrMethodName;

                rangeDuraction.Value2 = "Duration";
                rangeDuraction.Font.Bold = true;

                rangeStart.Value2 = "Start";
                rangeStart.Font.Bold = true;

                rangeEnd.Value2 = "End";
                rangeEnd.Font.Bold = true;

                rangeErrors.Value2 = "Errors";
                rangeErrors.Font.Bold = true;
            }
        }
开发者ID:potatoit,项目名称:M3_WebServiceDataload,代码行数:28,代码来源:MainWindow.xaml.cs

示例8: generateSpreadsheetColumnsRecursive

        private int generateSpreadsheetColumnsRecursive(PropertyInfo[] apiProperties, Microsoft.Office.Interop.Excel.Worksheet awsWorksheet, int aiCurrentColumn)
        {
            int result = aiCurrentColumn;
            foreach (PropertyInfo currentProperty in apiProperties)
            {
                if (true == isPrimative(currentProperty.PropertyType))
                {
                    Microsoft.Office.Interop.Excel.Range rangeName = awsWorksheet.get_Range(GetColumnLetter(aiCurrentColumn) + (iDataVerticalStartPosition - 2));
                    Microsoft.Office.Interop.Excel.Range rangeType = awsWorksheet.get_Range(GetColumnLetter(aiCurrentColumn) + (iDataVerticalStartPosition + 1 - 2));

                    rangeName.Value2 = currentProperty.Name;
                    rangeName.Font.Bold = true;

                    rangeType.Value2 = extractHumanReadableType(currentProperty.PropertyType.ToString());
                    rangeType.Font.Italic = true;

                    aiCurrentColumn++;
                }
                else
                {
                    //Microsoft.Office.Interop.Excel.Range rangeName = awsWorksheet.get_Range(GetColumnLetter(aiCurrentColumn) + (iDataVerticalStartPosition - 3));
                    //Microsoft.Office.Interop.Excel.Range rangeType = awsWorksheet.get_Range(GetColumnLetter(aiCurrentColumn) + (iDataVerticalStartPosition - 4));

                    //rangeName.Value2 = currentProperty.Name;
                    //rangeName.Font.Bold = true;

                    //rangeType.Value2 = extractHumanReadableType(currentProperty.PropertyType.ToString());
                    //rangeType.Font.Italic = true;
                    aiCurrentColumn = generateSpreadsheetColumnsRecursive(currentProperty.PropertyType.GetProperties(), awsWorksheet, aiCurrentColumn);

                }
            }
            result = aiCurrentColumn;
            return (result);
        }
开发者ID:potatoit,项目名称:M3_WebServiceDataload,代码行数:35,代码来源:MainWindow.xaml.cs

示例9: SetRowHeight

 /// <summary>
 /// 设置行高
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 /// <param name="dblHeight">行高</param>
 public void SetRowHeight(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, double dblHeight)
 {
     CurSheet.get_Range(objStartCell, objEndCell).RowHeight = dblHeight;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs

示例10: SetNumberFormat

 /// <summary>
 /// 设置连续区域的显示格式
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 /// <param name="strNF">如"#,##0.00"的显示格式</param>
 public void SetNumberFormat(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, string strNF)
 {
     CurSheet.get_Range(objStartCell, objEndCell).NumberFormat = strNF;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs

示例11: SetHAlignRight

 /// <summary>
 /// 设置连续区域水平居右
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 public void SetHAlignRight(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell)
 {
     CurSheet.get_Range(objStartCell, objEndCell).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:10,代码来源:ExcelOperate.cs

示例12: SetFormula

 /// <summary>
 /// 为单元格设置公式
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objCell">单元格</param>
 /// <param name="strFormula">公式</param>
 public void SetFormula(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objCell, string strFormula)
 {
     CurSheet.get_Range(objCell, mValue).Formula = strFormula;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:10,代码来源:ExcelOperate.cs

示例13: SetFontSize

 /// <summary>
 /// 设置连续区域的字体大小
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="strStartCell">开始单元格</param>
 /// <param name="strEndCell">结束单元格</param>
 /// <param name="intFontSize">字体大小</param>
 public void SetFontSize(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, int intFontSize)
 {
     CurSheet.get_Range(objStartCell, objEndCell).Font.Size = intFontSize.ToString();
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs

示例14: SetFontName

 /// <summary>
 /// 设置连续区域的字体名称
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 /// <param name="fontname">字体名称 隶书、仿宋_GB2312等</param>
 public void SetFontName(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, string fontname)
 {
     CurSheet.get_Range(objStartCell, objEndCell).Font.Name = fontname;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs

示例15: SetColumnWidth

 /// <summary>
 /// 设置列宽
 /// </summary>
 /// <param name="CurSheet">Worksheet</param>
 /// <param name="objStartCell">开始单元格</param>
 /// <param name="objEndCell">结束单元格</param>
 /// <param name="dblWidth">宽度</param>
 public void SetColumnWidth(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objStartCell, object objEndCell, double dblWidth)
 {
     CurSheet.get_Range(objStartCell, objEndCell).ColumnWidth = dblWidth;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:11,代码来源:ExcelOperate.cs


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