public static bool IsDrillThroughEnabled(Excel.Range rngCell) { try { Excel.PivotTable pt = rngCell.PivotTable; // throws error if selected cell is not pivot cell Excel.PivotCache cache = pt.PivotCache(); Excel.Workbook workbook = rngCell.Worksheet.Parent; if (!cache.OLAP) { return(false); } if (ExcelHelper.CountXmlNamespace(workbook, Constants.DaxDrillXmlSchemaSpace) == 0) { return(false); } // check compatibility of Tabular database var queryClient = new QueryClient(rngCell); var connString = ExcelHelper.GetConnectionString(rngCell); if (!queryClient.IsDatabaseCompatible(connString)) { return(false); } return(true); } catch { return(false); } }
public QueryClient(Excel.Range rngCell, PivotCellDictionary pivotCellDic, IEnumerable <string> pivotFieldNames) { this.rngCell = rngCell; this.pivotTable = rngCell.PivotTable; this.pcache = pivotTable.PivotCache(); this.connectionString = pcache.Connection; this.pivotFieldNames = pivotFieldNames ?? PivotCellHelper.GetPivotFieldNames(rngCell); this.pivotCellDic = pivotCellDic ?? PivotCellHelper.GetPivotCellQuery(rngCell); }
public static Excel.WorkbookConnection GetWorkbookConnection(Excel.Range rngCell) { Excel.PivotTable pt = null; Excel.PivotCache cache = null; Excel.WorkbookConnection wbcnn = null; pt = rngCell.PivotTable; cache = pt.PivotCache(); wbcnn = cache.WorkbookConnection; return(wbcnn); }
public static string GetConnectionString(Excel.Range rngCell) { Excel.PivotTable pt = null; Excel.PivotCache cache = null; string connString; pt = rngCell.PivotTable; cache = pt.PivotCache(); connString = cache.Connection; return(connString); }