本文整理汇总了C#中Table.Append方法的典型用法代码示例。如果您正苦于以下问题:C# Table.Append方法的具体用法?C# Table.Append怎么用?C# Table.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateReport
public void generateReport(Client client)
{
string fileNameWithDate = "PlanOfCare(" + client.ClientID + client.FirstName + " " +
client.LastName + ") " + DateTime.Now.Month + "." + DateTime.Now.Day +
"." + DateTime.Now.Year + " " + DateTime.Now.Hour + "." + DateTime.Now.Minute +
"." + DateTime.Now.Second;
this.filePath = @"C:\MyClients\WordReports\" + fileNameWithDate + ".docx";
string xmlStylePath = @"C:\MyClients\References\styles.xml";
this.contentType = "application/msword";
this.fileName = client.LastName + "_" + client.FirstName + "_PlanOfCare.docx";
#region create document part
// todo: make filename unique
WordprocessingDocument document = WordprocessingDocument.Create(
this.filePath,
WordprocessingDocumentType.Document
);
// create "document" part
MainDocumentPart mainDocumentPart = document.AddMainDocumentPart();
mainDocumentPart.Document = new Document();
// create body of the document
Body documentBody = new Body();
mainDocumentPart.Document.Append(documentBody);
#endregion
#region create style part
// create "style" part
StyleDefinitionsPart styleDefinitionsPart =
mainDocumentPart.AddNewPart<StyleDefinitionsPart>();
// open style xml
// todo: reference this xml locally somehow
FileStream stylesTemplate =
new FileStream(xmlStylePath, FileMode.Open, FileAccess.Read);
styleDefinitionsPart.FeedData(stylesTemplate);
styleDefinitionsPart.Styles.Save();
#endregion
#region create title
// create paragraph for title
Paragraph titleParagraphe = new Paragraph();
// create paragraph properties
ParagraphProperties titleProperties = new ParagraphProperties();
// todo: figure out more styles and how these styles work
// make the paragraph a "title"
titleProperties.ParagraphStyleId = new ParagraphStyleId { Val = "Title" };
// apply the style properties to the paragraph
titleParagraphe.Append(titleProperties);
// create RUN, append TEXT to RUN, append RUN to PARAGRAPH
Run titleRun = new Run();
Text titleText = new Text("Plan of Care for " + client.FirstName + " " + client.LastName);
titleRun.Append(titleText);
titleParagraphe.Append(titleRun);
// append PARAGRAPH to BODY
documentBody.Append(titleParagraphe);
#endregion
#region create first heading (Client Details)
// add client name
Paragraph clientDetailsHeadingParagraph = new Paragraph();
// create styling
ParagraphProperties clientDetailsHeadingProperties = new ParagraphProperties();
clientDetailsHeadingProperties.ParagraphStyleId = new ParagraphStyleId { Val = "Heading1" };
clientDetailsHeadingParagraph.Append(clientDetailsHeadingProperties);
// create run/text of client info
Run clientDetailsHeadingRun = new Run();
Text clientDetailsHeadingText = new Text("Contact Information");
// append text to document
clientDetailsHeadingRun.Append(clientDetailsHeadingText);
clientDetailsHeadingParagraph.Append(clientDetailsHeadingRun);
documentBody.Append(clientDetailsHeadingParagraph);
#endregion
// create details table
Table addressTable = new Table();
#region address label
// create row/cell for address label
TableRow addressLabelRow = new TableRow();
TableCell addressLabelCell = new TableCell();
Paragraph addressLabelPgh = new Paragraph();
// create paragraph properties
addressLabelPgh.Append(new ParagraphProperties
{
SpacingBetweenLines = new SpacingBetweenLines { After = "0" }
});
// create run properties
RunProperties addressLabelRunProperties = new RunProperties();
addressLabelRunProperties.Append(new Bold());
// create label text to append to cell
//.........这里部分代码省略.........
示例2: GenerateTable
public Table GenerateTable(List<string> colwidths, List<string> headers)
{
this.colwidths = colwidths;
Table table1 = new Table();
TableProperties tableProperties1 = new TableProperties();
TableWidth tableWidth1 = new TableWidth() { Width = "8750", Type = TableWidthUnitValues.Dxa };
TableLayout tableLayout1 = new TableLayout() { Type = TableLayoutValues.Fixed };
TableIndentation tableIndentation1 = new TableIndentation() { Width = 108, Type = TableWidthUnitValues.Dxa };
TableLook tableLook1 = new TableLook() { Val = "04A0" };
tableProperties1.Append(tableWidth1);
tableProperties1.Append(tableIndentation1);
tableProperties1.Append(tableLayout1);
tableProperties1.Append(tableLook1);
TableGrid tableGrid1 = new TableGrid();
GridColumn gridColumn;
foreach (string cw in colwidths) {
gridColumn = new GridColumn() { Width = cw };
tableGrid1.Append(gridColumn);
}
TableRow headerRow = generateHeaderRow(headers);
table1.Append(tableProperties1);
table1.Append(tableGrid1);
table1.Append(headerRow);
return table1;
}
示例3: EasyTable
//Creates "2x2" table
//with default properties applied
public EasyTable()
{
Properties properties = Properties.byDefault;
table = new Table();
TableRow tr;
TableCell tc;
//Adding default borders
AddBorders(properties);
//Two rows
for (int i = 0; i < 2; i++ )
{
tr = new TableRow();
//Two cells in each row
for (int j = 0; j < 2; j++ )
{
//Empty table cell with no identation
tc = new TableCell(new Paragraph
(new ParagraphProperties
(new Indentation() { FirstLine = "0" }),
(new Run
(new Text("")))));
tr.Append(tc);
}
table.Append(tr);
}
}
示例4: CreateTable
// Adds child parts and generates content of the specified part.
public static void CreateTable(WorkbookPart workbookPart, WorksheetPart worksheetPart, string[] columns, int topLeftColumn, int topLeftRow, int width, int height)
{
List<WorksheetPart> worksheets = workbookPart.GetPartsOfType<WorksheetPart>().ToList();
uint maxTableId = worksheets.Select(ws => ws.TableDefinitionParts.ToList()).SelectMany(tableDefinitions => tableDefinitions).Aggregate<TableDefinitionPart, uint>(0, (current, tableDef) => Math.Max(tableDef.Table.Id, current));
uint tableId = maxTableId + 1;
var tables = new TableParts { Count = 1U };
worksheetPart.Worksheet.Append((IEnumerable<OpenXmlElement>)tables);
var newTableDefnPart = worksheetPart.AddNewPart<TableDefinitionPart>();
string relationshipId = worksheetPart.GetIdOfPart(newTableDefnPart);
string cellReference = string.Format("{0}{1}:{2}{3}", GetColumnIdentifier(topLeftColumn), topLeftRow, GetColumnIdentifier(topLeftColumn + width - 1), topLeftRow + height);
var table1 = new Table { Id = tableId, Name = "Table" + relationshipId, DisplayName = "Table" + relationshipId, Reference = cellReference, TotalsRowShown = false };
var autoFilter1 = new AutoFilter { Reference = cellReference };
var tableColumns1 = new TableColumns { Count = (uint)columns.Length };
for (int iColumn = 0; iColumn < columns.Length; iColumn++)
{
var tableColumn = new TableColumn { Id = (UInt32Value)(uint)iColumn + 1, Name = columns[iColumn] };
tableColumns1.Append((IEnumerable<OpenXmlElement>)tableColumn);
}
var tableStyleInfo1 = new TableStyleInfo { Name = "TableStyleMedium2", ShowFirstColumn = false, ShowLastColumn = false, ShowRowStripes = true, ShowColumnStripes = false };
table1.Append((IEnumerable<OpenXmlElement>)autoFilter1);
table1.Append((IEnumerable<OpenXmlElement>)tableColumns1);
table1.Append((IEnumerable<OpenXmlElement>)tableStyleInfo1);
newTableDefnPart.Table = table1;
var table = new TablePart { Id = relationshipId };
tables.Append((IEnumerable<OpenXmlElement>)table);
//TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleMedium9" };
//worksheetPart.Worksheet.Append(tableStyles1);
}
示例5: ToOpenXmlElements
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
{
Table result = new Table();
var tableProperties = new TableProperties();
var tableStyle = new TableStyle() { Val = "GrilledutableauSimpleTable" };
var tableWidth = UnitHelper.Convert(Width).To<TableWidth>();
var tableIndentation = new TableIndentation() { Width = 534, Type = TableWidthUnitValues.Dxa };
var tableLook = new TableLook() { Val = "04A0" };
tableProperties.Append(tableStyle);
tableProperties.Append(tableWidth);
tableProperties.Append(tableIndentation);
tableProperties.Append(tableLook);
result.Append(tableProperties);
ForEachChild(x =>
{
Debug.Assert(x is TableRowFormattedElement);
result.Append(x.ToOpenXmlElements(mainDocumentPart));
});
return new List<OpenXmlElement> { result };
}
示例6: CreateTable
private static Table CreateTable(IEnumerable<string> names)
{
Table table = new Table(
new TableProperties(
new TableWidth()
{
Width = "5000",
Type = TableWidthUnitValues.Pct
}
)
);
foreach (var name in names)
{
table.Append(
CreateTableRow(name)
);
}
return table;
}
开发者ID:mrolstone,项目名称:20532-DevelopingMicrosoftAzureSolutions,代码行数:20,代码来源:SignInDocumentGenerator.cs
示例7: GenerateChapterSix23
private void GenerateChapterSix23()
{
var paraProp = new ParagraphProperties();
var paragraph = new Paragraph();
var runProp = new RunProperties();
var run = new Run();
#region chapterSix23
var chapterSix23 = _sessionObjects.ChapterSixPartTwoThree;
runProp = new RunProperties
{
Bold = new Bold(),
Italic = new Italic()
};
run.Append(runProp);
run.Append(new Text(chapterSix23.SubHeader1));
paraProp = GetParagraphProperties("StyleWithoutIndentation");
GenerateParagraph(run, paraProp);
#region table
var table = new Table();
table.Append(GenerateTableProperties());
var tableGrid1 = new TableGrid();
tableGrid1.Append(new GridColumn { Width = "1843" });
tableGrid1.Append(new GridColumn { Width = "6716" });
table.Append(tableGrid1);
#region header
#region row
var tableRow = new TableRow();
#region cell
var tableCell = new TableCell();
TableCellProperties tableCellProperties1 = new TableCellProperties();
tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
tableCell.Append(tableCellProperties1);
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
var justification = new Justification() { Val = JustificationValues.Center };
paraProp.Append(spacingBetweenLines);
paraProp.Append(justification);
run = new Run();
runProp = new RunProperties
{
Bold = new Bold(),
Italic = new Italic()
};
run.Append(runProp);
run.Append(new Text("№ Занятия"));
paragraph.Append(paraProp);
paragraph.Append(run);
tableCell.Append(paragraph);
tableRow.Append(tableCell);
#endregion
#region cell
tableCell = new TableCell();
tableCellProperties1 = new TableCellProperties();
tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
tableCell.Append(tableCellProperties1);
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
justification = new Justification() { Val = JustificationValues.Center };
paraProp.Append(spacingBetweenLines);
paraProp.Append(justification);
run = new Run();
runProp = new RunProperties
{
Bold = new Bold(),
Italic = new Italic()
};
run.Append(runProp);
run.Append(new Text("Тема смостоятельного занятия"));
paragraph.Append(paraProp);
paragraph.Append(run);
tableCell.Append(paragraph);
tableRow.Append(tableCell);
#endregion
table.Append(tableRow);
#endregion
#endregion
#region data
for (var i = 0; i < chapterSix23.IndependentWork.Rows.Count; i++)
{
#region row
tableRow = new TableRow();
#region cell
tableCell = new TableCell();
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
justification = new Justification() { Val = JustificationValues.Center };
//.........这里部分代码省略.........
示例8: WriteVariables
private void WriteVariables(Body body)
{
Paragraph p = CreateMidashi1Paragraph("3. " + Resources.VariableSummary); //変数の概要
body.Append(p);
ObservableCollection<QuestionVM> questions = studyUnit.AllQuestions;
foreach (VariableVM variable in studyUnit.Variables)
{
StringBuilder buf = new StringBuilder();
buf.Append(variable.Title);
buf.Append(" ");
buf.Append(variable.Label);
buf.Append(" (");
buf.Append(variable.Response.TypeName);
buf.Append(" )");
p = CreateParagraph(buf.ToString());
body.Append(p);
QuestionVM question = EDOUtils.Find<QuestionVM>(questions, variable.QuestionId);
buf = new StringBuilder();
buf.Append(Resources.CorrespondingQuestionSentence); //対応する質問文
if (question != null)
{
buf.Append(" " + question.Text);
}
//質問文の段落
p = CreateParagraph(buf.ToString());
body.Append(p);
if (variable.Response.IsTypeChoices)
{
p = CreateEmptyParagraph();
body.Append(p);
Table table = new Table();
body.Append(table);
TableProperties tableProperties = new TableProperties();
DocumentFormat.OpenXml.Wordprocessing.TableStyle tableStyle = new DocumentFormat.OpenXml.Wordprocessing.TableStyle() { Val = "TableGrid" };
TableWidth tableWidth = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto };
TableLook tableLook = new TableLook()
{
Val = "04A0",
FirstRow = true,
LastRow = false,
FirstColumn = true,
LastColumn = false,
NoHorizontalBand = false,
NoVerticalBand = true
};
tableProperties.Append(tableStyle);
tableProperties.Append(tableWidth);
tableProperties.Append(tableLook);
table.Append(tableProperties);
TableRow tableRow = new TableRow();
table.Append(tableRow);
TableCell tableCell1 = new TableCell();
tableCell1.Append(CreateParagraph(Resources.Code));
tableRow.Append(tableCell1);
TableCell tableCell2 = new TableCell();
tableCell2.Append(CreateParagraph(Resources.Category));
tableRow.Append(tableCell2);
TableCell tableCell3 = new TableCell();
tableCell3.Append(CreateParagraph(Resources.Total));
tableRow.Append(tableCell3);
ObservableCollection<CodeVM> codes = variable.Response.Codes;
foreach (CodeVM code in codes)
{
tableRow = new TableRow();
table.Append(tableRow);
tableCell1 = new TableCell();
tableCell1.Append(CreateParagraph(code.Value));
tableRow.Append(tableCell1);
tableCell2 = new TableCell();
tableCell2.Append(CreateParagraph(code.Label));
tableRow.Append(tableCell2);
tableCell3 = new TableCell();
tableCell3.Append(CreateEmptyParagraph());
tableRow.Append(tableCell3);
}
}
//空の段落
p = CreateEmptyParagraph();
body.Append(p);
}
p = CreateBreakPageParagraph();
body.Append(p);
}
示例9: GenerateChapterFourTable1
private void GenerateChapterFourTable1()
{
var chapterFour = (ChapterFour)_sessionObjects.ChapterFour;
var discipline = (Discipline)_additionalObjects.Discipline;
var paraProp = new ParagraphProperties();
var paragraph = new Paragraph();
var runProp = new RunProperties();
var run = new Run();
var runs = new List<Run>();
var table = new Table();
table.Append(GenerateTableProperties());
var tableGrid1 = new TableGrid();
for (var i = 0; i < chapterFour.AuditoriumHours.Columns.Count + 1; i++)
{
var gridColumn1 = new GridColumn();
if (i == 0)
{
gridColumn1.Width = "4536";
}
else
{
gridColumn1.Width = "1200";
}
tableGrid1.Append(gridColumn1);
}
table.Append(tableGrid1);
#region Шапка
#region row
var tableRow = new TableRow();
#region cell
var tableCell = new TableCell();
TableCellProperties tableCellProperties1 = new TableCellProperties();
tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
tableCell.Append(tableCellProperties1);
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
var justification = new Justification() { Val = JustificationValues.Center };
paraProp.Append(spacingBetweenLines);
paraProp.Append(justification);
run = new Run();
runProp = new RunProperties
{
Bold = new Bold(),
Italic = new Italic()
};
run.Append(runProp);
run.Append(new Text("Вид учебной работы"));
paragraph.Append(paraProp);
paragraph.Append(run);
tableCell.Append(paragraph);
tableRow.Append(tableCell);
#endregion
#region cell
tableCell = new TableCell();
tableCellProperties1 = new TableCellProperties();
tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
tableCell.Append(tableCellProperties1);
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
justification = new Justification() { Val = JustificationValues.Center };
paraProp.Append(spacingBetweenLines);
paraProp.Append(justification);
run = new Run();
runProp = new RunProperties
{
Bold = new Bold(),
Italic = new Italic()
};
run.Append(runProp);
run.Append(new Text("Всего зачетных единиц / часов"));
paragraph.Append(paraProp);
paragraph.Append(run);
tableCell.Append(paragraph);
tableRow.Append(tableCell);
#endregion
#region cell
tableCell = new TableCell();
tableCellProperties1 = new TableCellProperties();
tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
tableCellProperties1.Append(new GridSpan() { Val = 2 });
tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
tableCell.Append(tableCellProperties1);
paragraph = new Paragraph();
paraProp = GetParagraphProperties("TableStyle");
spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
justification = new Justification() { Val = JustificationValues.Center };
paraProp.Append(spacingBetweenLines);
//.........这里部分代码省略.........
示例10: CreateFilledTable
private Table CreateFilledTable(bool hasBorder, bool hasInsideBorder)
{
//枠線有りテーブルを生成する(幅はページの幅)
Table table = new Table();
TableProperties tableProperties = new TableProperties();
TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };
TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };
TableLook tableLook = new TableLook()
{
Val = "04A0",
FirstRow = true,
LastRow = false,
FirstColumn = true,
LastColumn = false,
NoHorizontalBand = false,
NoVerticalBand = true
};
tableProperties.Append(tableStyle);
tableProperties.Append(tableWidth);
tableProperties.Append(tableLook);
TableBorders borders = new TableBorders();
tableProperties.Append(borders);
EnumValue<BorderValues> val = hasBorder ? BorderValues.Single : BorderValues.Nil;
TopBorder topBorder = new TopBorder() { Val = val };
BottomBorder bottomBorder = new BottomBorder() { Val = val };
LeftBorder leftBorder = new LeftBorder() { Val = val };
RightBorder rightBorder = new RightBorder() { Val = val };
borders.Append(topBorder);
borders.Append(bottomBorder);
borders.Append(leftBorder);
borders.Append(rightBorder);
val = hasInsideBorder ? BorderValues.Single : BorderValues.Nil;
InsideHorizontalBorder horizontalBorder = new InsideHorizontalBorder() { Val = val };
InsideVerticalBorder verticalBorder = new InsideVerticalBorder() { Val = val };
borders.Append(horizontalBorder);
borders.Append(verticalBorder);
table.Append(tableProperties);
return table;
}
示例11: saveReportToWord
/*Создание отчёта в Word*/
private void saveReportToWord(string fileName)
{
// Create a Wordprocessing document.
using (WordprocessingDocument myDoc =
WordprocessingDocument.Create(fileName,
WordprocessingDocumentType.Document))
{
MainDocumentPart mainPart = myDoc.AddMainDocumentPart();
mainPart.Document = new Document();
Body body = new Body();
Table resultTable = new Table();
Table table = new Table();
TableProperties tblPr = new TableProperties();
TableBorders tblBorders = new TableBorders();
tblBorders.TopBorder = new TopBorder();
tblBorders.TopBorder.Val = BorderValues.Single;
tblBorders.BottomBorder = new BottomBorder();
tblBorders.BottomBorder.Val = BorderValues.Single;
tblBorders.LeftBorder = new LeftBorder();
tblBorders.LeftBorder.Val = BorderValues.Single;
tblBorders.RightBorder = new RightBorder();
tblBorders.RightBorder.Val = BorderValues.Single;
tblBorders.InsideHorizontalBorder = new InsideHorizontalBorder();
tblBorders.InsideHorizontalBorder.Val = BorderValues.Single;
tblBorders.InsideVerticalBorder = new InsideVerticalBorder();
tblBorders.InsideVerticalBorder.Val = BorderValues.Single;
tblPr.Append(tblBorders);
table.Append(tblPr);
TableRow tr;
TableCell tc;
tr = new TableRow();
body.Append(new Paragraph(new Run(new Text("Эксперимент: " + Experiment.Name.ToString() + "\n"))));
body.Append(new Paragraph(new Run(new Text("Отклик: " + dgwExperiment.Columns[dgwExperiment.Columns.Count - 1].HeaderCell.Value.ToString() + "\n"))));
if (dgwExperiment.Columns.Count == 2)
{
body.Append(new Paragraph(new Run(new Text("Фактор: "))));
}
else
{
body.Append(new Paragraph(new Run(new Text("Факторы: "))));
}
for (int col = 0; col < dgwExperiment.Columns.Count - 1; col++)
{
body.Append(new Paragraph(new Run(new Text(dgwExperiment.Columns[col].HeaderCell.Value.ToString() + "\n"))));
}
body.Append(new Paragraph(new Run(new Text("\n\n"))));
tc = new TableCell(new Paragraph(new Run(
new Text("Экспериментальные данные"))));
TableCellProperties tcp = new TableCellProperties();
GridSpan gridSpan = new GridSpan();
gridSpan.Val = 11;
tcp.Append(gridSpan);
tc.Append(tcp);
tr.Append(tc);
table.Append(tr);
tr = new TableRow();
tc = new TableCell();
tc.Append(new Paragraph(new Run(new Text("*"))));
tr.Append(tc);
for (int i = 0; i < dgwExperiment.Columns.Count; i++)
{
tr.Append(new TableCell(new Paragraph(new Run(new Text(dgwExperiment.Columns[i].HeaderCell.Value.ToString())))));
}
table.Append(tr);
for (int i = 0; i < dgwExperiment.Rows.Count; i++)
{
tr = new TableRow();
tr.Append(new TableCell(new Paragraph(new Run(new Text(dgwExperiment.Rows[i].HeaderCell.Value.ToString())))));
for (int j = 0; j < dgwExperiment.Columns.Count; j++)
{
tr.Append(new TableCell(new Paragraph(new Run(new Text( dgwExperiment.Rows[i].Cells[j].Value.ToString())))));
}
table.Append(tr);
}
body.Append(table);
body.Append(new Paragraph(new Run(new Text("\n\n"))));
body.Append(new Paragraph(new Run(new Text("Результаты синтеза модели\n"))));
for (int i = 0; i < txtCalcResult.Lines.Length; i++)
{
body.Append(new Paragraph(new Run(new Text(txtCalcResult.Lines[i].ToString()))));
}
body.Append(new Paragraph(new Run(new Text("\n\n"))));
/*
TableRowHeight a = new TableRowHeight();
a.HeightType = HeightRuleValues.Auto;
*/
//.........这里部分代码省略.........
示例12: GenerateBasiceReportDataTable
private Table GenerateBasiceReportDataTable()
{
Table table1 = new Table();
TableProperties tableProperties1 = new TableProperties();
TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" };
TablePositionProperties tablePositionProperties1 = new TablePositionProperties() { LeftFromText = 180, RightFromText = 180, VerticalAnchor = VerticalAnchorValues.Text, HorizontalAnchor = HorizontalAnchorValues.Margin, TablePositionXAlignment = HorizontalAlignmentValues.Center, TablePositionY = 103 };
TableWidth tableWidth1 = new TableWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa };
TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true };
tableProperties1.Append(tableStyle1);
tableProperties1.Append(tablePositionProperties1);
tableProperties1.Append(tableWidth1);
tableProperties1.Append(tableLook1);
TableGrid tableGrid1 = new TableGrid();
GridColumn gridColumn1 = new GridColumn() { Width = "15026" };
tableGrid1.Append(gridColumn1);
TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "004E307B", RsidTableRowProperties = "00D273DB" };
TableCell tableCell1 = new TableCell();
TableCellProperties tableCellProperties1 = new TableCellProperties();
TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa };
tableCellProperties1.Append(tableCellWidth1);
Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "004E307B", RsidParagraphAddition = "004E307B", RsidParagraphProperties = "004E307B", RsidRunAdditionDefault = "004E307B" };
ParagraphProperties paragraphProperties1 = new ParagraphProperties();
Justification justification1 = new Justification() { Val = JustificationValues.Center };
paragraphProperties1.Append(justification1);
paragraph1.Append(paragraphProperties1);
tableCell1.Append(tableCellProperties1);
tableCell1.Append(paragraph1);
tableRow1.Append(tableCell1);
table1.Append(tableProperties1);
table1.Append(tableGrid1);
table1.Append(tableRow1);
return table1;
}
示例13: GenerateTable
// Creates an Table instance and adds its children.
public static Table GenerateTable(Document doc, System.Data.DataTable datetable)
{
Table table = new Table();
//
PageSize pagesize = doc.Body.Descendants<PageSize>().First();
PageMargin pagemargin = doc.Body.Descendants<PageMargin>().First();
//
var AvailableSumWidth = (int)(pagesize.Width - pagemargin.Right - pagemargin.Left);
TableBorders tborder = new Func<TableBorders>(delegate()
{
TableBorders tableBorders1 = new TableBorders();
TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
tableBorders1.Append(topBorder1);
tableBorders1.Append(leftBorder1);
tableBorders1.Append(bottomBorder1);
tableBorders1.Append(rightBorder1);
tableBorders1.Append(insideHorizontalBorder1);
tableBorders1.Append(insideVerticalBorder1);
return tableBorders1;
})();
table.AppendChild<TableProperties>(new TableProperties(
new TableStyle() { Val = "a7" },
tborder,
new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto },
new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }
));
int sumColumn = datetable.Columns.Count;
int averwidth = AvailableSumWidth / sumColumn;
Double set_colSumW = 0;
int remainSumW = 0;
foreach (System.Data.DataColumn item in datetable.Columns)
{
Object col_w = item.ExtendedProperties["width"];
if (col_w != null) { set_colSumW += Convert.ToDouble(col_w); remainSumW += averwidth; }
}
foreach (System.Data.DataColumn item in datetable.Columns)
{
Object col_w = item.ExtendedProperties["width"];
if (col_w != null) item.ExtendedProperties.Add("WordWidth", Math.Floor((remainSumW * Convert.ToDouble(col_w) / set_colSumW)));
else item.ExtendedProperties.Add("WordWidth", averwidth);
}
for (int i = 0; i < sumColumn; i++)
{
int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);
table.AppendChild<GridColumn>(new GridColumn() { Width = col_w.ToString() });
}
List<System.Data.DataRow> lstCol = new List<System.Data.DataRow>();
System.Data.DataRow dr = datetable.NewRow();
List<object> lstObj = new List<object>();
foreach (System.Data.DataColumn item in datetable.Columns)
{
lstObj.Add(item.ColumnName);
}
dr.ItemArray = lstObj.ToArray();
datetable.Rows.InsertAt(dr, 0);
foreach (System.Data.DataRow item in datetable.Rows)
{
TableRow tableRow = new TableRow() { RsidTableRowAddition = "00D24D12", RsidTableRowProperties = "00D24D12" };
for (int i = 0; i < sumColumn; i++)
{
int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);
string cellValue = item[i].ToString();
TableCell tableCell1 = new TableCell();
TableCellProperties tableCellProperties1 = new TableCellProperties();
TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = col_w.ToString(), Type = TableWidthUnitValues.Dxa };
tableCellProperties1.Append(tableCellWidth1);
Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00D24D12", RsidParagraphProperties = "003246FB", RsidRunAdditionDefault = "00D24D12" };
Run run1 = new Run();
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };
runProperties1.Append(runFonts1);
Text text1 = new Text();
text1.Text = cellValue;
run1.Append(runProperties1);
run1.Append(text1);
//.........这里部分代码省略.........
示例14: AddRows
private static void AddRows(DataTable table, TableStyle tableStyle, Table wordTable, TableProperties tableProperties)
{
for (int r = 0; r < table.Rows.Count; r++) {
// Create a row.
TableRow tRow = new TableRow();
for (int c = 0; c < table.Columns.Count; c++) {
// Create a cell.
TableCell tCell = new TableCell();
if ((r % 2 == 0) && (tableStyle.EnableAlternativeBackgroundColor)) {
var tCellProperties = new TableCellProperties();
// Set Cell Color
Shading tCellColor = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = System.Drawing.ColorTranslator.ToHtml(tableStyle.AlternativeBackgroundColor) };
tCellProperties.Append(tCellColor);
tCell.Append(tCellProperties);
}
string rowContent = table.Rows[r][c] == null ? string.Empty : table.Rows[r][c].ToString();
ParagraphProperties paragProperties = new ParagraphProperties();
SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" };
paragProperties.Append(spacingBetweenLines1);
Run run = new Run();
if (rowContent.Contains(Environment.NewLine)) {
string[] lines = rowContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++) {
var line = lines[i];
if (i > 0) {
run.AppendChild(new Break());
}
Text newText = new Text(line);
run.AppendChild<Text>(newText);
}
}
else {
Text newText = new Text(rowContent);
run.AppendChild<Text>(newText);
}
ApplyFontProperties(tableStyle, RowIdentification.Row, run);
var parag = new Paragraph();
parag.Append(paragProperties);
parag.Append(run);
// Specify the table cell content.
tCell.Append(parag);
// Append the table cell to the table row.
tRow.Append(tCell);
}
// Append the table row to the table.
wordTable.Append(tRow);
}
}
示例15: AddHeaderRow
private static void AddHeaderRow(DataTable table, Table wordTable, TableStyle tableStyle)
{
// Create a row.
TableRow tRow = new TableRow();
foreach (DataColumn iColumn in table.Columns) {
// Create a cell.
TableCell tCell = new TableCell();
TableCellProperties tCellProperties = new TableCellProperties();
// Set Cell Color
Shading tCellColor = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = System.Drawing.ColorTranslator.ToHtml(tableStyle.HeaderBackgroundColor) };
tCellProperties.Append(tCellColor);
// Append properties to the cell
tCell.Append(tCellProperties);
ParagraphProperties paragProperties = new ParagraphProperties();
Justification justification1 = new Justification() { Val = JustificationValues.Center };
SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" };
paragProperties.Append(spacingBetweenLines1);
paragProperties.Append(justification1);
var parag = new Paragraph();
parag.Append(paragProperties);
var run = new Run(new Text(iColumn.ColumnName));
ApplyFontProperties(tableStyle, RowIdentification.Header, run);
parag.Append(run);
// Specify the table cell content.
tCell.Append(parag);
// Append the table cell to the table row.
tRow.Append(tCell);
}
// Append the table row to the table.
wordTable.Append(tRow);
}