|
|
|
@@ -17,7 +17,7 @@ namespace Novacode |
|
|
|
{
|
|
|
|
private Alignment alignment;
|
|
|
|
private AutoFit autofit;
|
|
|
|
private float[] ColumnWidths;
|
|
|
|
private float[] ColumnWidthsValue;
|
|
|
|
/// <summary>
|
|
|
|
/// Merge cells in given column starting with startRow and ending with endRow.
|
|
|
|
/// </summary>
|
|
|
|
@@ -191,7 +191,7 @@ namespace Novacode |
|
|
|
|
|
|
|
public void SetWidths(float[] widths)
|
|
|
|
{
|
|
|
|
this.ColumnWidths = widths;
|
|
|
|
this.ColumnWidthsValue = widths;
|
|
|
|
//set widths for existing rows
|
|
|
|
foreach (var r in Rows)
|
|
|
|
{
|
|
|
|
@@ -226,7 +226,7 @@ namespace Novacode |
|
|
|
return tblPr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the column width for a given column index.
|
|
|
|
/// </summary>
|
|
|
|
@@ -235,7 +235,7 @@ namespace Novacode |
|
|
|
{
|
|
|
|
List<Double> widths = ColumnWidths;
|
|
|
|
if (widths == null || index > widths.Count -1) return Double.NaN;
|
|
|
|
|
|
|
|
|
|
|
|
return widths[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -284,7 +284,7 @@ namespace Novacode |
|
|
|
{
|
|
|
|
value = w;
|
|
|
|
if (i == index) value = width;
|
|
|
|
gridCol = new XElement(XName.Get("gridCol", DocX.w.NamespaceName),
|
|
|
|
gridCol = new XElement(XName.Get("gridCol", DocX.w.NamespaceName),
|
|
|
|
new XAttribute(XName.Get("w", DocX.w.NamespaceName), value));
|
|
|
|
grid.Add(gridCol);
|
|
|
|
i += 1;
|
|
|
|
@@ -298,9 +298,9 @@ namespace Novacode |
|
|
|
|
|
|
|
// set fitting to fixed; this will add/set additional table properties
|
|
|
|
this.AutoFit = AutoFit.Fixed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a list of all column widths for this table.
|
|
|
|
/// </summary>
|
|
|
|
@@ -442,14 +442,14 @@ namespace Novacode |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// String containing the Table Caption value (the table's Alternate Text Title)
|
|
|
|
/// </summary>
|
|
|
|
private string _tableCaption;
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or Sets the value of the Table Caption (Alternate Text Title) of this table.
|
|
|
|
/// </summary>
|
|
|
|
public string TableCaption
|
|
|
|
/// <summary>
|
|
|
|
/// String containing the Table Caption value (the table's Alternate Text Title)
|
|
|
|
/// </summary>
|
|
|
|
private string _tableCaption;
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or Sets the value of the Table Caption (Alternate Text Title) of this table.
|
|
|
|
/// </summary>
|
|
|
|
public string TableCaption
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
@@ -464,7 +464,7 @@ namespace Novacode |
|
|
|
|
|
|
|
tblCaption = new XElement(XName.Get("tblCaption", DocX.w.NamespaceName),
|
|
|
|
new XAttribute(XName.Get("val", DocX.w.NamespaceName), value));
|
|
|
|
tblPr.Add(tblCaption);
|
|
|
|
tblPr.Add(tblCaption);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1407,8 +1407,8 @@ namespace Novacode |
|
|
|
for (int i = 0; i < ColumnCount; i++)
|
|
|
|
{
|
|
|
|
var w = 2310d;
|
|
|
|
if (ColumnWidths != null && ColumnWidths.Length > i)
|
|
|
|
w = ColumnWidths[i] * 15;
|
|
|
|
if (ColumnWidthsValue != null && ColumnWidthsValue.Length > i)
|
|
|
|
w = ColumnWidthsValue[i] * 15;
|
|
|
|
XElement cell = HelperFunctions.CreateTableCell(w);
|
|
|
|
content.Add(cell);
|
|
|
|
}
|
|
|
|
@@ -1977,80 +1977,80 @@ namespace Novacode |
|
|
|
/// </example>
|
|
|
|
/// <param name="borderType">The table border to set</param>
|
|
|
|
/// <param name="border">Border object to set the table border</param>
|
|
|
|
public void SetBorder(TableBorderType borderType, Border border)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Get the tblPr (table properties) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
XElement tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
|
|
|
|
if (tblPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("tblPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the tblBorders (table borders) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
XElement tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
|
|
|
|
if (tblBorders == null)
|
|
|
|
{
|
|
|
|
tblPr.SetElementValue(XName.Get("tblBorders", DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the 'borderType' (table border) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
string tbordertype;
|
|
|
|
tbordertype = borderType.ToString();
|
|
|
|
// only lower the first char of string (because of insideH and insideV)
|
|
|
|
tbordertype = tbordertype.Substring(0, 1).ToLower() + tbordertype.Substring(1);
|
|
|
|
|
|
|
|
XElement tblBorderType = tblBorders.Element(XName.Get(borderType.ToString(), DocX.w.NamespaceName));
|
|
|
|
if (tblBorderType == null)
|
|
|
|
{
|
|
|
|
tblBorders.SetElementValue(XName.Get(tbordertype, DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblBorderType = tblBorders.Element(XName.Get(tbordertype, DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
// get string value of border style
|
|
|
|
string borderstyle = border.Tcbs.ToString().Substring(5);
|
|
|
|
borderstyle = borderstyle.Substring(0, 1).ToLower() + borderstyle.Substring(1);
|
|
|
|
|
|
|
|
// The val attribute is used for the border style
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), borderstyle);
|
|
|
|
|
|
|
|
if (border.Tcbs != BorderStyle.Tcbs_nil)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
switch (border.Size)
|
|
|
|
{
|
|
|
|
case BorderSize.one: size = 2; break;
|
|
|
|
case BorderSize.two: size = 4; break;
|
|
|
|
case BorderSize.three: size = 6; break;
|
|
|
|
case BorderSize.four: size = 8; break;
|
|
|
|
case BorderSize.five: size = 12; break;
|
|
|
|
case BorderSize.six: size = 18; break;
|
|
|
|
case BorderSize.seven: size = 24; break;
|
|
|
|
case BorderSize.eight: size = 36; break;
|
|
|
|
case BorderSize.nine: size = 48; break;
|
|
|
|
default: size = 2; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The sz attribute is used for the border size
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("sz", DocX.w.NamespaceName), (size).ToString());
|
|
|
|
|
|
|
|
// The space attribute is used for the cell spacing (probably '0')
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());
|
|
|
|
|
|
|
|
// The color attribute is used for the border color
|
|
|
|
public void SetBorder(TableBorderType borderType, Border border)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Get the tblPr (table properties) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
XElement tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
|
|
|
|
if (tblPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("tblPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the tblBorders (table borders) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
XElement tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
|
|
|
|
if (tblBorders == null)
|
|
|
|
{
|
|
|
|
tblPr.SetElementValue(XName.Get("tblBorders", DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the 'borderType' (table border) element for this Table,
|
|
|
|
* null will be return if no such element exists.
|
|
|
|
*/
|
|
|
|
string tbordertype;
|
|
|
|
tbordertype = borderType.ToString();
|
|
|
|
// only lower the first char of string (because of insideH and insideV)
|
|
|
|
tbordertype = tbordertype.Substring(0, 1).ToLower() + tbordertype.Substring(1);
|
|
|
|
|
|
|
|
XElement tblBorderType = tblBorders.Element(XName.Get(borderType.ToString(), DocX.w.NamespaceName));
|
|
|
|
if (tblBorderType == null)
|
|
|
|
{
|
|
|
|
tblBorders.SetElementValue(XName.Get(tbordertype, DocX.w.NamespaceName), string.Empty);
|
|
|
|
tblBorderType = tblBorders.Element(XName.Get(tbordertype, DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
// get string value of border style
|
|
|
|
string borderstyle = border.Tcbs.ToString().Substring(5);
|
|
|
|
borderstyle = borderstyle.Substring(0, 1).ToLower() + borderstyle.Substring(1);
|
|
|
|
|
|
|
|
// The val attribute is used for the border style
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), borderstyle);
|
|
|
|
|
|
|
|
if (border.Tcbs != BorderStyle.Tcbs_nil)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
switch (border.Size)
|
|
|
|
{
|
|
|
|
case BorderSize.one: size = 2; break;
|
|
|
|
case BorderSize.two: size = 4; break;
|
|
|
|
case BorderSize.three: size = 6; break;
|
|
|
|
case BorderSize.four: size = 8; break;
|
|
|
|
case BorderSize.five: size = 12; break;
|
|
|
|
case BorderSize.six: size = 18; break;
|
|
|
|
case BorderSize.seven: size = 24; break;
|
|
|
|
case BorderSize.eight: size = 36; break;
|
|
|
|
case BorderSize.nine: size = 48; break;
|
|
|
|
default: size = 2; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The sz attribute is used for the border size
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("sz", DocX.w.NamespaceName), (size).ToString());
|
|
|
|
|
|
|
|
// The space attribute is used for the cell spacing (probably '0')
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());
|
|
|
|
|
|
|
|
// The color attribute is used for the border color
|
|
|
|
tblBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), border.Color.ToHex());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a table border
|
|
|
|
@@ -2192,7 +2192,7 @@ namespace Novacode |
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -2406,44 +2406,44 @@ namespace Novacode |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Set to true to make this row the table header row that will be repeated on each page
|
|
|
|
/// </summary>
|
|
|
|
public bool TableHeader
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName));
|
|
|
|
if (tblHeader == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("trPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName));
|
|
|
|
if (tblHeader == null && value)
|
|
|
|
{
|
|
|
|
trPr.SetElementValue(XName.Get("tblHeader", DocX.w.NamespaceName), string.Empty);
|
|
|
|
}
|
|
|
|
if (tblHeader != null && !value)
|
|
|
|
{
|
|
|
|
tblHeader.Remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set to true to make this row the table header row that will be repeated on each page
|
|
|
|
/// </summary>
|
|
|
|
public bool TableHeader
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName));
|
|
|
|
if (tblHeader == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("trPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName));
|
|
|
|
if (tblHeader == null && value)
|
|
|
|
{
|
|
|
|
trPr.SetElementValue(XName.Get("tblHeader", DocX.w.NamespaceName), string.Empty);
|
|
|
|
}
|
|
|
|
if (tblHeader != null && !value)
|
|
|
|
{
|
|
|
|
tblHeader.Remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Allow row to break across pages.
|
|
|
|
/// The default value is true: Word will break the contents of the row across pages.
|
|
|
|
@@ -2451,48 +2451,48 @@ namespace Novacode |
|
|
|
/// </summary>
|
|
|
|
public bool BreakAcrossPages
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
|
|
|
|
if (trPr == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
|
|
|
|
if (trCantSplit == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == false)
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("trPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
if (trCantSplit == null)
|
|
|
|
trPr.SetElementValue(XName.Get("cantSplit", DocX.w.NamespaceName), string.Empty);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value == true)
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr != null)
|
|
|
|
{
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
if (trCantSplit != null)
|
|
|
|
trCantSplit.Remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
get
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
|
|
|
|
if (trPr == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
|
|
|
|
if (trCantSplit == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == false)
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr == null)
|
|
|
|
{
|
|
|
|
Xml.SetElementValue(XName.Get("trPr", DocX.w.NamespaceName), string.Empty);
|
|
|
|
trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
if (trCantSplit == null)
|
|
|
|
trPr.SetElementValue(XName.Get("cantSplit", DocX.w.NamespaceName), string.Empty);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value == true)
|
|
|
|
{
|
|
|
|
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
|
|
|
|
if (trPr != null)
|
|
|
|
{
|
|
|
|
XElement trCantSplit = trPr.Element(XName.Get("cantSplit", DocX.w.NamespaceName));
|
|
|
|
if (trCantSplit != null)
|
|
|
|
trCantSplit.Remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -2849,7 +2849,7 @@ namespace Novacode |
|
|
|
if (value == -1)
|
|
|
|
{
|
|
|
|
// remove cell width; due to set on table prop.
|
|
|
|
tcW.Remove();
|
|
|
|
tcW.Remove();
|
|
|
|
return;
|
|
|
|
|
|
|
|
//tcW.SetAttributeValue(XName.Get("type", DocX.w.NamespaceName), "auto");
|
|
|
|
@@ -3770,5 +3770,5 @@ namespace Novacode |
|
|
|
public bool NoHorizontalBanding { get; set; }
|
|
|
|
public bool NoVerticalBanding { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|