Exemplo n.º 1
0
        /// <summary>
        ///     给定单元格所在 工作簿中 是否包含 该工作表
        /// </summary>
        /// <param name="range"></param>
        /// <param name="sheetName"></param>
        /// <returns></returns>
        public static bool HasWorksheet(this ExcelReference range, string sheetName)
        {
            string workName = range.WorkbookName();

            try{
                object result = XlCall.Excel(XlCall.xlfGetDocument, 76, $"[{workName}]{sheetName}");
                return(!result.IsNull());
            } catch (Exception) {
                return(false);
            }
        }