/// <summary> /// Creates the cell style. /// </summary> /// <param name="styleNode">The style node.</param> private void CreateCellStyle(XmlNode styleNode) { CellStyle cellStyle = new CellStyle(this._document); cellStyle.Node = styleNode.CloneNode(true); IPropertyCollection pCollection = new IPropertyCollection(); if (styleNode.HasChildNodes) { foreach(XmlNode node in styleNode.ChildNodes) { IProperty property = this.GetProperty(cellStyle, node.CloneNode(true)); if (property != null) pCollection.Add(property); } } cellStyle.Node.InnerXml = ""; foreach(IProperty property in pCollection) cellStyle.PropertyCollection.Add(property); if (!this._common) this._document.Styles.Add(cellStyle); else this._document.CommonStyles.Add(cellStyle); }
/// <summary> /// Gets the cell style as HTML. /// </summary> /// <param name="cellStyle">The cell style.</param> /// <returns></returns> public string GetCellStyleAsHtml(CellStyle cellStyle) { string style = ""; try { if (cellStyle != null) { if (cellStyle.CellProperties != null) { if (cellStyle.CellProperties.BackgroundColor != null) style += "bgcolor=\""+cellStyle.CellProperties.BackgroundColor+"\" "; } } } catch(Exception ex) { throw new AODLException("Exception while trying to build a HTML style string from a CellStyle.", ex); } return style; }
/// <summary> /// Initializes a new instance of the <see cref="CellProperties"/> class. /// </summary> /// <param name="cellstyle">The cellstyle.</param> public CellProperties(CellStyle cellstyle) { this.CellStyle = cellstyle; this.NewXmlNode(); //TODO: Check localisations cm?? inch?? //defaults this.Padding = "0.097cm"; }
/// <summary> /// Gets the cell style as HTML. /// </summary> /// <param name="cellStyle">The cell style.</param> /// <returns></returns> public string GetCellStyleAsHtml(CellStyle cellStyle) { string style = ""; try { if(cellStyle != null) { if(cellStyle.CellProperties != null) { if(cellStyle.CellProperties.BackgroundColor != null) style += "bgcolor=\""+cellStyle.CellProperties.BackgroundColor+"\" "; } } } catch(Exception ex) { AODLException exception = new AODLException("Exception while trying to build a HTML style string from a CellStyle."); exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); exception.OriginalException = ex; if(cellStyle != null) if(cellStyle.Node != null) exception.Node = cellStyle.Node; throw exception; } return style; }