public static string GetCellHyperlinksAddress( [ExcelArgument(Description = "带链接的单元格", AllowReference = true)] object srcRange) { ExcelReference excelReference = srcRange as ExcelReference; IExcel.Range excelRange = excelReference.ToPiaRange(); return(excelRange.Hyperlinks[1].Address); }
private static int GetArrNum() { int arrNum; ExcelReference caller = XlCall.Excel(XlCall.xlfCaller) as ExcelReference; IExcel.Range range = caller.ToPiaRange(); int firstRowIndex = range.Row; IExcel.Range currentRegion = range.CurrentRegion; arrNum = currentRegion.Rows.Count + currentRegion.Row - 1 - firstRowIndex + 1; return(arrNum); }
public static double GetCellIndentLevel( [ExcelArgument(Description = "引用单元格", AllowReference = true)] object srcRange) { IExcel.Range excelRange; if (srcRange is ExcelMissing) { IExcel.Application app = ExcelDnaUtil.Application as IExcel.Application; excelRange = app.ActiveCell; } ExcelReference excelReference = srcRange as ExcelReference; excelRange = excelReference.ToPiaRange(); return(excelRange.IndentLevel); }
public static object GetCellFormular( [ExcelArgument(Description = "带公式的单元格", AllowReference = true)] object srcRange) { ExcelReference excelReference = srcRange as ExcelReference; IExcel.Range excelRange = excelReference.ToPiaRange(); if (excelRange.Cells.Count > 1) { return(ExcelError.ExcelErrorNA); } else { return(excelRange.Formula); } }
public static object GetCellNumberFormat( [ExcelArgument(Description = "引用单元格", AllowReference = true)] object srcCell) { ExcelReference excelReference = srcCell as ExcelReference; IExcel.Range excelRange = excelReference.ToPiaRange(); if (excelRange.Cells.Count > 1) { return(ExcelError.ExcelErrorNA); } else { return(excelRange.NumberFormatLocal); } }
public static object GetCellCommentText( [ExcelArgument(Description = "带批注的单元格", AllowReference = true)] object srcRange) { ExcelReference excelReference = srcRange as ExcelReference; IExcel.Range excelRange = excelReference.ToPiaRange(); if (excelRange.Cells.Count > 1) { return(ExcelError.ExcelErrorNA); } else { if (excelRange.Comment != null) { return(excelRange.Comment.Text()); } else { return(ExcelEmpty.Value); } } }
public static object GetRangeAddress( [ExcelArgument(Description = "输入需获取地址的单元格区域,获取本身地址可省略输入", AllowReference = true)] object srcRange, [ExcelArgument(Description = "是否绝对引用返回引用的行部分,默认为否")] bool isRowAbsolute, [ExcelArgument(Description = "是否绝对引用返回引用的列部分,默认为否")] bool isColumnAbsolute) { IExcel.Range excelRange = null; if (srcRange is ExcelMissing) { excelRange = Common.ExcelApp.ActiveCell; } else { ExcelReference excelReference = srcRange as ExcelReference; if (excelReference != null) { excelRange = excelReference.ToPiaRange(); } else { return(ExcelError.ExcelErrorRef); } } return(excelRange.Address[isRowAbsolute, isColumnAbsolute]); }
static public Excel.Range GetCaller() { ExcelReference caller = XlCall.Excel(XlCall.xlfCaller) as ExcelReference; return(caller.ToPiaRange()); }