/** * Creates a Cell Style from the supplied parts * @param cellXfId The main XF for the cell. Must be a valid 0-based index into the XF table * @param cellStyleXfId Optional, style xf. A value of <code>-1</code> means no xf. * @param stylesSource Styles Source to work off */ public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource, ThemesTable theme) { _cellXfId = cellXfId; _stylesSource = stylesSource; _cellXf = stylesSource.GetCellXfAt(this._cellXfId); _cellStyleXf = cellStyleXfId == -1 ? null : stylesSource.GetCellStyleXfAt(cellStyleXfId); _theme = theme; }
/** * If there isn't currently a {@link ThemesTable} for the * current Workbook, then creates one and sets it up. * After this, calls to {@link #getTheme()} won't give null */ public void EnsureThemesTable() { if (theme != null) { return; } theme = (ThemesTable)workbook.CreateRelationship(XSSFRelation.THEME, XSSFFactory.GetInstance()); }
public void SetTheme(ThemesTable theme) { this.theme = theme; foreach (XSSFFont font in this.fonts) { font.SetThemesTable(theme); } foreach (XSSFCellBorder border in this.borders) { border.SetThemesTable(theme); } }
public void SetTheme(ThemesTable theme) { this.theme = theme; // Pass the themes table along to things which need to // know about it, but have already been Created by now foreach (XSSFFont font in fonts) { font.SetThemesTable(theme); } foreach (XSSFCellBorder border in borders) { border.SetThemesTable(theme); } }
internal override void OnDocumentRead() { try { XmlDocument xmldoc = ConvertStreamToXml(GetPackagePart().GetInputStream()); doc = WorkbookDocument.Parse(xmldoc, NamespaceManager); this.workbook = doc.Workbook; Dictionary<String, XSSFSheet> shIdMap = new Dictionary<String, XSSFSheet>(); Dictionary<String, ExternalLinksTable> elIdMap = new Dictionary<String, ExternalLinksTable>(); foreach (POIXMLDocumentPart p in GetRelations()) { if (p is SharedStringsTable) sharedStringSource = (SharedStringsTable)p; else if (p is StylesTable) stylesSource = (StylesTable)p; else if (p is ThemesTable) theme = (ThemesTable)p; else if (p is CalculationChain) calcChain = (CalculationChain)p; else if (p is MapInfo) mapInfo = (MapInfo)p; else if (p is XSSFSheet) { shIdMap.Add(p.GetPackageRelationship().Id,(XSSFSheet)p); } else if (p is ExternalLinksTable) { elIdMap.Add(p.GetPackageRelationship().Id, (ExternalLinksTable)p); } } bool packageReadOnly = (Package.GetPackageAccess() == PackageAccess.READ); if (stylesSource == null) { // Create Styles if it is missing if (packageReadOnly) { stylesSource = new StylesTable(); } else { stylesSource = (StylesTable)CreateRelationship(XSSFRelation.STYLES, XSSFFactory.GetInstance()); } } stylesSource.SetTheme(theme); if (sharedStringSource == null) { //Create SST if it is missing if (packageReadOnly) { sharedStringSource = new SharedStringsTable(); } else { sharedStringSource = (SharedStringsTable)CreateRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.GetInstance()); } } // Load individual sheets. The order of sheets is defined by the order // of CTSheet elements in the workbook sheets = new List<XSSFSheet>(shIdMap.Count); foreach (CT_Sheet ctSheet in this.workbook.sheets.sheet) { XSSFSheet sh = null; if(shIdMap.ContainsKey(ctSheet.id)) sh = shIdMap[ctSheet.id]; if (sh == null) { logger.Log(POILogger.WARN, "Sheet with name " + ctSheet.name + " and r:id " + ctSheet.id + " was defined, but didn't exist in package, skipping"); continue; } sh.sheet = ctSheet; sh.OnDocumentRead(); sheets.Add(sh); } // Load the external links tables. Their order is defined by the order // of CTExternalReference elements in the workbook externalLinks = new List<ExternalLinksTable>(elIdMap.Count); if (this.workbook.IsSetExternalReferences()) { foreach (CT_ExternalReference er in this.workbook.externalReferences.externalReference) { ExternalLinksTable el = null; if(elIdMap.ContainsKey(er.id)) el = elIdMap[(er.id)]; if (el == null) { logger.Log(POILogger.WARN, "ExternalLinksTable with r:id " + er.id + " was defined, but didn't exist in package, skipping"); continue; } externalLinks.Add(el); } } // Process the named ranges ReprocessNamedRanges(); } catch (XmlException e) { throw new POIXMLException(e); } }
internal override void OnDocumentRead() { try { XmlDocument xmldoc = ConvertStreamToXml(GetPackagePart().GetInputStream()); doc = WorkbookDocument.Parse(xmldoc, NamespaceManager); this.workbook = doc.Workbook; Dictionary<String, XSSFSheet> shIdMap = new Dictionary<String, XSSFSheet>(); foreach (POIXMLDocumentPart p in GetRelations()) { if (p is SharedStringsTable) sharedStringSource = (SharedStringsTable)p; else if (p is StylesTable) stylesSource = (StylesTable)p; else if (p is ThemesTable) theme = (ThemesTable)p; else if (p is CalculationChain) calcChain = (CalculationChain)p; else if (p is MapInfo) mapInfo = (MapInfo)p; else if (p is XSSFSheet) { shIdMap.Add(p.GetPackageRelationship().Id,(XSSFSheet)p); } } if (null != stylesSource) { stylesSource.SetTheme(theme); } if (sharedStringSource == null) { //Create SST if it is missing sharedStringSource = (SharedStringsTable)CreateRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.GetInstance()); } // Load individual sheets. The order of sheets is defined by the order of CT_Sheet elements in the workbook sheets = new List<XSSFSheet>(shIdMap.Count); foreach (CT_Sheet ctSheet in this.workbook.sheets.sheet) { XSSFSheet sh = shIdMap[ctSheet.id]; if (sh == null) { logger.Log(POILogger.WARN, "Sheet with name " + ctSheet.name + " and r:id " + ctSheet.id + " was defined, but didn't exist in package, skipping"); continue; } sh.sheet = ctSheet; sh.OnDocumentRead(); sheets.Add(sh); } // Process the named ranges namedRanges = new List<XSSFName>(); if (workbook.IsSetDefinedNames()) { foreach (CT_DefinedName ctName in workbook.definedNames.definedName) { namedRanges.Add(new XSSFName(ctName, this)); } } } catch (XmlException e) { throw new POIXMLException(e); } }
/** * Records the Themes Table that is associated with * the current font, used when looking up theme * based colours and properties. */ public void SetThemesTable(ThemesTable themes) { this._themes = themes; }
///** // * Perform a registration of ourselves // * to the style table // */ public long RegisterTo(StylesTable styles) { this._themes = styles.GetTheme(); short idx = (short)styles.PutFont(this, true); this._index = idx; return idx; }
/** * Creates a Cell Border from the supplied XML defInition */ public XSSFCellBorder(CT_Border border, ThemesTable theme) : this(border) { this._theme = theme; }