Пример #1
0
        /// <summary>
        /// Gets the table style as HTML.
        /// </summary>
        /// <param name="tableStyle">The table style.</param>
        /// <returns></returns>
        public string GetTableStyleAsHtml(TableStyle tableStyle)
        {
            string style = "";

            try
            {
                if (tableStyle != null)
                {
                    if (tableStyle.TableProperties != null)
                    {
                        if (tableStyle.TableProperties.Width != null)
                        {
                            string width = tableStyle.TableProperties.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 (tableStyle.TableProperties.Width.EndsWith("cm"))
                                {
                                    wdPx = SizeConverter.CmToPixelAsString(wd);
                                }
                                else if (tableStyle.TableProperties.Width.EndsWith("in"))
                                {
                                    wdPx = SizeConverter.InchToPixelAsString(wd);
                                }

                                if (wdPx.Length > 0)
                                {
                                    style = "width=\"" + wdPx.Replace("px", "") + "\" ";
                                }
                            }
                            catch (Exception ex)
                            {
                                if (this.OnWarning != null)
                                {
                                    AODLWarning warning = new AODLWarning("Exception while trying to build a table width width.: "
                                                                          + tableStyle.TableProperties.Width, ex);
                                    //warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                                    //warning.OriginalException	= ex;
                                    OnWarning(warning);
                                }
                            }
                        }
                        if (tableStyle.TableProperties.Align != null)
                        {
                            if (tableStyle.TableProperties.Align != "margin")
                            {
                                if (tableStyle.TableProperties.Align == "center")
                                {
                                    style += "align=\"center\" ";
                                }
                                else if (tableStyle.TableProperties.Align == "right")
                                {
                                    style += "align=\"center\" ";                                       //Because display prob by some browser
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new AODLException("Exception while trying to build a HTML style string from a TableStyle.", ex);
            }

            return(style);
        }
Пример #2
0
        /// <summary>
        /// Gets the frame style as HTML.
        /// </summary>
        /// <param name="frame">The frame.</param>
        /// <returns></returns>
        public string GetFrameStyleAsHtml(Frame frame)
        {
            string style = "";

            try
            {
                if (frame != null)
                {
                    string width = frame.SvgWidth;
                    if (width != null)
                    {
                        if (width.EndsWith("cm"))
                        {
                            width = width.Replace("cm", "");
                        }
                        else if (width.EndsWith("in"))
                        {
                            width = width.Replace("in", "");
                        }
                    }

                    string height = frame.SvgHeight;
                    if (height != null)
                    {
                        if (height.EndsWith("cm"))
                        {
                            height = height.Replace("cm", "");
                        }
                        else if (height.EndsWith("in"))
                        {
                            height = height.Replace("in", "");
                        }
                    }

                    try
                    {
                        if (width != null)
                        {
                            double wd   = Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo);
                            string wdPx = "";
                            if (frame.SvgWidth.EndsWith("cm"))
                            {
                                wdPx = SizeConverter.CmToPixelAsString(wd);
                            }
                            else if (frame.SvgWidth.EndsWith("in"))
                            {
                                wdPx = SizeConverter.InchToPixelAsString(wd);
                            }

                            if (wdPx.Length > 0)
                            {
                                style = "width=\"" + wdPx + "\" ";
                            }
                        }

                        if (height != null)
                        {
                            double wd   = Convert.ToDouble(height, System.Globalization.NumberFormatInfo.InvariantInfo);
                            string wdPx = "";
                            if (frame.SvgHeight.EndsWith("cm"))
                            {
                                wdPx = SizeConverter.CmToPixelAsString(wd);
                            }
                            else if (frame.SvgHeight.EndsWith("in"))
                            {
                                wdPx = SizeConverter.InchToPixelAsString(wd);
                            }

                            if (wdPx.Length > 0)
                            {
                                style = "height=\"" + wdPx + "\" ";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (this.OnWarning != null)
                        {
                            AODLWarning warning = new AODLWarning("Exception while trying to build a graphic width & height.: "
                                                                  + frame.SvgWidth + "/" + frame.SvgHeight, 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 FrameStyle.", ex);
            }

            return(style);
        }
Пример #3
0
        /// <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);
        }