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;
}