本文整理汇总了C#中Novacode.DocX.InsertParagraph方法的典型用法代码示例。如果您正苦于以下问题:C# DocX.InsertParagraph方法的具体用法?C# DocX.InsertParagraph怎么用?C# DocX.InsertParagraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.DocX
的用法示例。
在下文中一共展示了DocX.InsertParagraph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _Create
private void _Create(string file, IEnumerable<OXmlElement> elements)
{
using (_document = DocX.Create(file))
{
foreach (OXmlElement element in elements)
{
switch (element.Type)
{
//case zDocXElementType.BeginParagraph:
// _paragraph = _document.InsertParagraph();
// break;
//case zDocXElementType.EndParagraph:
// _paragraph = null;
// break;
case OXmlElementType.Paragraph:
_paragraph = _document.InsertParagraph();
break;
case OXmlElementType.Text:
AddText(element);
break;
case OXmlElementType.Line:
AddLine();
break;
case OXmlElementType.Picture:
AddPicture(element);
break;
}
}
_document.Save();
}
}
示例2: CreateHeader
private static void CreateHeader(DocX doc)
{
string headerText = "SoftUni OOP Game Contest";
var headerFormat = new Formatting();
headerFormat.FontFamily = new FontFamily("Tahoma");
headerFormat.Size = 18D;
headerFormat.Position = 12;
var header = doc.InsertParagraph(headerText, false, headerFormat);
header.Alignment = Alignment.center;
}
示例3: AddParagraph
/// <summary>
///
/// </summary>
/// <param name="lines"></param>
/// <param name="doc"></param>
public static void AddParagraph(List<List<string>> lines, DocX doc)
{
Paragraph p = doc.InsertParagraph();
List<List<string>> l = lines;
foreach (List<string> ss in l)
{
MatchCollection mc = Regex.Matches(ss[0], @"\{[0-9]+\}");
string temp = ss[0];
foreach (Match m in mc)
{
foreach (Capture c in m.Captures)
{
temp = temp.Replace(c.Value, "¬");
}
}
string[] temps = temp.Split('¬');
Append(p, temps[0]);
for (int i = 1; i < ss.Count; i++)
{
string pattern = @"\\(?<type>[a-zA-Z0-9]+)(?:\{(?<output>[^\{\}]+)\})?(?:\{(?<output2>[^\{\}]+)\})?";
Match m = Regex.Match(ss[i], pattern);
switch (m.Groups["type"].Value)
{
case "textbf":
Append(p, m.Groups["output"].Value);
p.Bold();
p.Append(temps[i]);
break;
case "emph":
case "textit":
Append(p, m.Groups["output"].Value);
p.Italic();
Append(p, temps[i]);
break;
case "rlap":
Append(p, m.Groups["output"].Value);
Append(p, m.Groups["output2"].Value);
break;
default:
throw new Exception(m.Groups["type"] + " is still under development");
}
}
string blah = doc.Xml.Value;
}
}
示例4: CreateImage
private static void CreateImage(DocX doc)
{
try
{
string imgPath = "rpg-game.png";
var pic = doc.AddImage(imgPath).CreatePicture();
var drawingImg = System.Drawing.Image.FromFile(imgPath);
int ratio = drawingImg.Width / drawingImg.Height;
int newWidth = (int)doc.PageWidth - (int)(doc.MarginLeft + doc.MarginRight);
pic.Width = newWidth;
pic.Height = newWidth / ratio;
doc.InsertParagraph().InsertPicture(pic);
}
catch (System.IO.FileNotFoundException ex)
{
System.Console.WriteLine(ex.Message);
}
}
示例5: InsertPicture
private static void InsertPicture(DocX doc, string filename, Formatting format)
{
using (MemoryStream memoryStream = new MemoryStream())
{
System.Drawing.Image myImg = System.Drawing.Image.FromFile(filename);
myImg.Save(memoryStream, myImg.RawFormat); // Save your picture in a memory stream.
memoryStream.Seek(0, SeekOrigin.Begin);
Novacode.Image img = doc.AddImage(memoryStream); // Create image.
Paragraph p = doc.InsertParagraph("", false);
Picture pic1 = img.CreatePicture(); // Create picture.
p.InsertPicture(pic1, 0); // Insert picture into paragraph.
doc.Save();
}
}
示例6: CreateFooter
private static void CreateFooter(DocX doc)
{
var footerFormat = new Formatting();
footerFormat.FontFamily = new FontFamily("Tahoma");
footerFormat.Size = 10D;
var p = doc.InsertParagraph("The top 3 teams will receive a ", false, footerFormat);
p.Alignment = Alignment.center;
footerFormat.Bold = true;
p.InsertText("SPECTACULAR ", false, footerFormat);
footerFormat.Bold = false;
p.InsertText("prize:\n");
footerFormat.Bold = true;
footerFormat.UnderlineStyle = UnderlineStyle.singleLine;
footerFormat.FontColor = System.Drawing.Color.MediumBlue;
footerFormat.Size = 14D;
p.InsertText("A HANDSHAKE FROM NAKOV", false, footerFormat);
}
示例7: PageBreakOrLineBreak
private void PageBreakOrLineBreak(DocX doc)
{
if (PageBreakBetweenFiles)
{
doc.InsertParagraph().InsertPageBreakAfterSelf();
}
else
{
doc.InsertParagraph();
}
}
示例8: PrintRevision
private void PrintRevision(IEnumerable<BarRevisionMyClass> revision, DocX doc)
{
BarRevisionController.BarRevisionControllerInstance().InsertOrUpdateAllItemsInBar();
for (int i = 0; i < 5; i++)
{
doc.InsertParagraph();
}
doc.InsertParagraph("Ревизия:");
var barRevisionMyClasses = revision as IList<BarRevisionMyClass> ?? revision.ToList();
doc.InsertTable(barRevisionMyClasses.Count()+2, 2);
doc.PageLayout.Orientation = Orientation.Landscape;
Table revisionTable = doc.Tables[2];
revisionTable.AutoFit = AutoFit.Contents;
revisionTable.Design = TableDesign.TableGrid;
revisionTable.Rows[0].Cells[0].Paragraphs[0].InsertText("Наименование");
revisionTable.Rows[0].Cells[1].Paragraphs[0].InsertText("Продано");
for (int i = 0; i < barRevisionMyClasses.Count(); i++)
{
revisionTable.Rows[i + 1].Cells[0].Paragraphs[0].InsertText(barRevisionMyClasses[i].Наименование);
revisionTable.Rows[i + 1].Cells[1].Paragraphs[0].InsertText(barRevisionMyClasses[i].Продано.ToString(CultureInfo.InvariantCulture));
}
foreach (var si in barRevisionMyClasses)
{
}
}
示例9: InsertMainText
private static void InsertMainText(DocX doc)
{
var textFormat = new Formatting();
textFormat.FontFamily = new FontFamily("Tahoma");
textFormat.Size = 10D;
var p = doc.InsertParagraph();
p.InsertText("SoftUni is organizing a contest for the best ", false, textFormat);
textFormat.Bold = true;
p.InsertText("role playing game", false, textFormat);
textFormat.Bold = false;
p.InsertText(" from the OOP teamwork projects. The winning teams will receive a ", false, textFormat);
textFormat.UnderlineStyle = UnderlineStyle.singleLine;
textFormat.Bold = true;
p.InsertText("grand prize", false, textFormat);
textFormat.UnderlineStyle = UnderlineStyle.none;
textFormat.Bold = false;
p.InsertText("!\nThe game should be:", false, textFormat);
}
示例10: buttonCreateDoc_Click
private void buttonCreateDoc_Click(object sender, EventArgs e)
{
if(saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "")
{
filename = saveFileDialog.FileName;
doc = DocX.Create(filename);
buttonAdProb.Enabled = true;
buttonAdProbRandom.Enabled = true;
buttonOpenDoc.Enabled = true;
Paragraph paragraph = doc.InsertParagraph("Test");
paragraph.Alignment = Alignment.center;
doc.InsertParagraph(Environment.NewLine);
doc.Save();
problemIndex = 0;
MessageBox.Show("Document creat cu succes!");
}
}
示例11: PrintExpenses
private void PrintExpenses(IEnumerable<expenses_t> allExpenses, DocX doc)
{
for (int i = 0; i < 5; i++)
{
doc.InsertParagraph();
}
doc.InsertParagraph("Таблица расходов: ");
foreach (expenses_t exp in allExpenses)
{
doc.InsertParagraph(exp.expenses_time.ToString("HH:mm") + ": " + exp.comments + " - " + exp.cash_amount + " сом");
}
}
示例12: InsertTesterSignature
private void InsertTesterSignature(DocX document2, string tester)
{
var textStyle = new Formatting();
textStyle.Size = 12;
textStyle.FontFamily = new System.Drawing.FontFamily("Times New Roman");
var signatureHeader = document2.InsertParagraph(
Environment.NewLine +
"Извършил изпитването:",
false,
textStyle
);
signatureHeader.IndentationBefore = 2;
var nameBox = document2.InsertParagraph(
"/" + tester + "/" + Environment.NewLine,
false,
textStyle
);
nameBox.IndentationBefore = 2;
}
示例13: PrepareHeaderInfoTable
private Table PrepareHeaderInfoTable(DocX document, HeaderInfoOutput headerInfo)
{
Paragraph subHeader = document.InsertParagraph();
subHeader.Alignment = Alignment.center;
subHeader.Append(System.IO.Path.GetFileName(headerInfo.HeaderName)).Bold().FontSize(14);
Table subHeaderTable = document.AddTable(headerInfo.Params.Count(), 2);
subHeaderTable.Alignment = Alignment.center;
subHeaderTable.Design = TableDesign.TableGrid;
int index = 0;
foreach (var entry in headerInfo.Params)
{
subHeaderTable.Rows[index].Cells[0].Paragraphs.First().Append(entry.Item1);
subHeaderTable.Rows[index].Cells[1].Paragraphs.First().Append(entry.Item2);
index++;
}
return subHeaderTable;
}
示例14: InsertRemarks
private void InsertRemarks(DocX document2)
{
var remarks = ReportModel.ReportParameters["Remarks"] as IEnumerable<ProtocolsRemark>;
StringBuilder remarksText = new StringBuilder();
foreach (var remark in remarks.OrderBy(r => r.Number))
{
if (remark.Remark != null)
remarksText.Append("\rЗабележка " + remark.Number + ": " + remark.Remark.Text + Environment.NewLine + Environment.NewLine);
}
var remarksParagraph = document2.InsertParagraph(remarksText.ToString());
remarksParagraph.IndentationBefore = 2;
}
示例15: InsertLabLeaderSignature
private void InsertLabLeaderSignature(DocX document2)
{
var labLeader = ReportModel.ReportParameters["LabLeader"] as string;
var textStyle = new Formatting();
textStyle.Size = 14;
textStyle.Bold = true;
textStyle.FontFamily = new System.Drawing.FontFamily("Times New Roman");
var labLeaderHeader = document2.InsertParagraph(
"Ръководител на лабораторията:",
false,
textStyle
);
labLeaderHeader.Alignment = Alignment.right;
labLeaderHeader.IndentationAfter = 2;
var ts2 = new Formatting();
ts2.Size = 14;
ts2.FontFamily = new System.Drawing.FontFamily("Times New Roman");
var nameBox = document2.InsertParagraph(
//Environment.NewLine +
"/" + labLeader + "/",
false,
ts2
);
nameBox.Alignment = Alignment.right;
nameBox.IndentationAfter = 1;
}