本文整理汇总了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);
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}