ColumnStyle represent a table column style.
Inheritance: IStyle
		/// <summary>
		/// Gets the column style as HTML.
		/// </summary>
		/// <param name="columnStyle">The column style.</param>
		/// <returns></returns>
		public string GetColumnStyleAsHtml(ColumnStyle columnStyle)
		{
			string style		= "";

			try
			{
				if (columnStyle != null)
				{
					if (columnStyle.ColumnProperties != null)
					{
						if (columnStyle.ColumnProperties.Width != null)
						{
							string width	= columnStyle.ColumnProperties.Width;
							if (width.EndsWith("cm"))
								width		= width.Replace("cm", "");
							else if (width.EndsWith("in"))
								width		= width.Replace("in", "");

							try
							{
								double wd	= Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo);
								string wdPx	= "";
								if (columnStyle.ColumnProperties.Width.EndsWith("cm"))
									wdPx	= SizeConverter.CmToPixelAsString(wd);
								else if (columnStyle.ColumnProperties.Width.EndsWith("in"))
									wdPx	= SizeConverter.InchToPixelAsString(wd);

								if (wdPx.Length > 0)
									style	= "width=\""+wdPx+"\" ";
							}
							catch(Exception ex)
							{
								if (this.OnWarning != null)
								{
									AODLWarning warning			= new AODLWarning("Exception while trying to build a column width.: "
										+ columnStyle.ColumnProperties.Width, ex);
									//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
									//warning.OriginalException	= ex;
									OnWarning(warning);
								}
							}							
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML style string from a CellStyle.", ex);
			}

			return style;
		}
		/// <summary>
		/// Creates the column style.
		/// </summary>
		/// <param name="styleNode">The style node.</param>
		private void CreateColumnStyle(XmlNode styleNode)
		{
			ColumnStyle columnStyle				= new ColumnStyle(this._document);
			columnStyle.Node						= styleNode.CloneNode(true);
			IPropertyCollection pCollection		= new IPropertyCollection();

			if (styleNode.HasChildNodes)
			{
				foreach(XmlNode node in styleNode.ChildNodes)
				{
					IProperty property			= this.GetProperty(columnStyle, node.CloneNode(true));
					if (property != null)
						pCollection.Add(property);
				}
			}

			columnStyle.Node.InnerXml			= "";

			foreach(IProperty property in pCollection)
				columnStyle.PropertyCollection.Add(property);

			if (!this._common)
				this._document.Styles.Add(columnStyle);
			else
				this._document.CommonStyles.Add(columnStyle);
		}
Example #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Column"/> class.
		/// </summary>
		/// <param name="table">The table.</param>
		/// <param name="styleName">Name of the style.</param>
		public Column(Table table, string styleName)
		{
			this.Table				= table;
			this.Document			= table.Document;
			this.NewXmlNode(styleName);
			this.ColumnStyle		= this.Document.StyleFactory.Request<ColumnStyle>(styleName);	
		}