public static void AssertRowSpacing4x4(CellState cell, float spacing, TableWidthUnitValues widthType) { for (int d = 0; d < 4; d++) { Assert.AreEqual(widthType, cell.Borders[d].SpacingType); } if (cell.ColumnIndex == 0) { Assert.AreEqual(spacing * 2, cell.Borders[3].Spacing); } else { Assert.AreEqual(spacing, cell.Borders[3].Spacing); } Assert.AreEqual(spacing, cell.Borders[0].Spacing); Assert.AreEqual(spacing, cell.Borders[2].Spacing); if (cell.ColumnIndex == 3) { Assert.AreEqual(spacing * 2, cell.Borders[1].Spacing); } else { Assert.AreEqual(spacing, cell.Borders[1].Spacing); } }
private static string GetUnitAsString(TableWidthUnitValues unitType) { if (unitType == TableWidthUnitValues.Dxa) { return("pt"); } return("%"); }
private TableCellSpacing BuildCellSpacing(float val, TableWidthUnitValues type) { var spacing = new TableCellSpacing { Type = type, Width = val.ToString() }; return(spacing); }
internal static bool TableUnitsFromStyle(string style, out decimal value, out TableWidthUnitValues unit) { unit = TableWidthUnitValues.Nil; if (!ConvertToPt(style, out value)) { return(false); } if (style.Contains("%")) { value = value * 50; //Convert to fifties unit = TableWidthUnitValues.Pct; return(true); } else { value = value * 20; //Convert to Twentieths of a point unit = TableWidthUnitValues.Dxa; return(true); } }
internal static bool TableUnitsFromStyle(string style, out decimal value, out TableWidthUnitValues unit) { unit = TableWidthUnitValues.Nil; if (!ConvertToPt(style, out value)) { return false; } if (style.Contains("%")) { value = value * 50;//Convert to fifties unit = TableWidthUnitValues.Pct; return true; } else { value = value * 20; //Convert to Twentieths of a point unit = TableWidthUnitValues.Dxa; return true; } }
/// <summary> /// default constructor /// </summary> public TableWidthModel() { Width = "5000"; Type = TableWidthUnitValues.Pct; }
/// <summary> /// Возвращает ячейку с настройками может применятся для создания строки /// </summary> /// <param name="paragraph">1 Параграф для добавления в ячейку</param> /// <param name="width">Длина ячейки 567 - 1 см </param> /// <param name="type">Тип выравнивания</param> /// <param name="leftmargin">Левый отступ в пикселях</param> /// <param name="rightmargin">Правый отступ в пикселях</param> /// <param name="borders">Стиль отражение границы ячейки</param> /// <param name="gridNumber">Объединение ячеек</param> /// <param name="verticalmerge">1 Начало объединения 2 конец объединения</param> /// <param name="colorHex">Цвет ячейки</param> /// <returns></returns> public static TableCell GenerateCell(Paragraph paragraph, string width, TableWidthUnitValues type, string leftmargin = "0", string rightmargin = "0", TableVerticalAlignmentValues verticalAlignment = TableVerticalAlignmentValues.Bottom, TableCellBorders borders = null, int gridNumber = 0, int verticalmerge = 0, string colorHex = "FFFFFF") { TableCell tableCell = new TableCell(); TableCellProperties tableCellProperties = new TableCellProperties(); TableCellWidth tableCellWidth = new TableCellWidth() { Width = width, Type = type }; GridSpan gridSpan = new GridSpan() { Val = gridNumber }; TableCellVerticalAlignment tcVA = new TableCellVerticalAlignment() { Val = verticalAlignment }; if (verticalmerge == 1) { VerticalMerge vertical = new VerticalMerge() { Val = MergedCellValues.Restart }; tableCellProperties.Append(vertical); } if (verticalmerge == 2) { VerticalMerge vertical = new VerticalMerge() { Val = MergedCellValues.Continue }; tableCellProperties.Append(vertical); } TableCellMargin tableCellMargin = new TableCellMargin(); if (leftmargin != "0") { LeftMargin leftMargin = new LeftMargin() { Width = leftmargin, Type = TableWidthUnitValues.Dxa }; tableCellMargin.Append(leftMargin); } if (rightmargin != "0") { RightMargin rightMargin = new RightMargin() { Width = rightmargin, Type = TableWidthUnitValues.Dxa }; tableCellMargin.Append(rightMargin); } Shading shading = new Shading() { Color = "auto", Fill = colorHex, Val = ShadingPatternValues.Clear }; tableCellProperties.Append(shading); tableCellProperties.Append(tcVA); tableCellProperties.Append(tableCellWidth); tableCellProperties.Append(tableCellMargin); tableCellProperties.Append(gridSpan); if (borders != null) { tableCellProperties.Append(borders); } tableCell.Append(tableCellProperties); tableCell.Append(paragraph); return(tableCell); }
/// <summary> /// Возвращает ячейку с настройками может применятся для создания строки /// </summary> /// <param name="paragraph">Коллекция параграффов для добавления в ячейку</param> /// <param name="number">Количество объединенных ячеек</param> /// <param name="width">Длина ячейки</param> /// <param name="type">Тип выравнивания</param> /// <param name="leftmargin">Левый отступ в пикселях</param> /// <param name="rightmargin">Правый отступ в пикселях</param> /// <param name="borders">Отражение границы ячейки</param> /// <returns></returns> public static TableCell GenerateCell(ref ObservableCollection <Paragraph> paragraph, string width, TableWidthUnitValues type, string leftmargin = "0", string rightmargin = "0", TableVerticalAlignmentValues verticalAlignment = TableVerticalAlignmentValues.Bottom, TableCellBorders borders = null, int number = 0) { TableCell tableCell = new TableCell(); TableCellProperties tableCellProperties = new TableCellProperties(); TableCellWidth tableCellWidth = new TableCellWidth() { Width = width, Type = type }; GridSpan gridSpan = new GridSpan() { Val = number }; TableCellVerticalAlignment tcVA = new TableCellVerticalAlignment() { Val = verticalAlignment }; TableCellMargin tableCellMargin = new TableCellMargin(); if (leftmargin != "0") { LeftMargin leftMargin = new LeftMargin() { Width = leftmargin, Type = TableWidthUnitValues.Dxa }; tableCellMargin.Append(leftMargin); } if (rightmargin != "0") { RightMargin rightMargin = new RightMargin() { Width = rightmargin, Type = TableWidthUnitValues.Dxa }; tableCellMargin.Append(rightMargin); } tableCellProperties.Append(tcVA); tableCellProperties.Append(tableCellWidth); tableCellProperties.Append(tableCellMargin); tableCellProperties.Append(gridSpan); if (borders != null) { tableCellProperties.Append(borders); } tableCell.Append(tableCellProperties); AddParagraphCell(ref tableCell, ref paragraph); return(tableCell); }
private TableCellProperties CreateCellProperties(TableWidthUnitValues unit, string width) { return new TableCellProperties(new TableCellWidth { Type = unit, Width = width }); }
public static bool OOxmlEquals(this TableWidthUnitValues value, TableWidthUnitValues compareValue) { return(((DocumentFormat.OpenXml.Wordprocessing.TableWidthUnitValues)(int) value).Equals(compareValue)); }
public static DocumentFormat.OpenXml.Wordprocessing.TableWidthUnitValues ToOOxml(this TableWidthUnitValues value) { return((DocumentFormat.OpenXml.Wordprocessing.TableWidthUnitValues)(int) value); }