本文整理汇总了C#中DocumentBuilder.EndTable方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.EndTable方法的具体用法?C# DocumentBuilder.EndTable怎么用?C# DocumentBuilder.EndTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.EndTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We call this method to start building the table.
builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, Cell 1 Content.");
// Build the second cell
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content.");
// Call the following method to end the row and start a new row.
builder.EndRow();
// Build the first cell of the second row.
builder.InsertCell();
builder.Write("Row 2, Cell 1 Content");
// Build the second cell.
builder.InsertCell();
builder.Write("Row 2, Cell 2 Content.");
builder.EndRow();
// Signal that we have finished building the table.
builder.EndTable();
// Save the document to disk.
doc.Save("DocumentBuilder.CreateSimpleTable Out.doc");
}
示例2: SimpleTable
private static void SimpleTable(string dataDir)
{
// ExStart:SimpleTable
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We call this method to start building the table.
builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, Cell 1 Content.");
// Build the second cell
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content.");
// Call the following method to end the row and start a new row.
builder.EndRow();
// Build the first cell of the second row.
builder.InsertCell();
builder.Write("Row 2, Cell 1 Content");
// Build the second cell.
builder.InsertCell();
builder.Write("Row 2, Cell 2 Content.");
builder.EndRow();
// Signal that we have finished building the table.
builder.EndTable();
dataDir = dataDir + "DocumentBuilder.CreateSimpleTable_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:SimpleTable
Console.WriteLine("\nSimple table created successfully.\nFile saved at " + dataDir);
}
示例3: HorizontalMerge
public void HorizontalMerge()
{
//ExStart
//ExFor:CellMerge
//ExFor:CellFormat.HorizontalMerge
//ExId:HorizontalMerge
//ExSummary:Creates a table with two rows with cells in the first row horizontally merged.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("Text in merged cells.");
builder.InsertCell();
// This cell is merged to the previous and should be empty.
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.EndRow();
builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("Text in one cell.");
builder.InsertCell();
builder.Write("Text in another cell.");
builder.EndRow();
builder.EndTable();
//ExEnd
}
示例4: VerticalMerge
public void VerticalMerge()
{
//ExStart
//ExFor:DocumentBuilder.InsertCell
//ExFor:DocumentBuilder.EndRow
//ExFor:CellMerge
//ExFor:CellFormat.VerticalMerge
//ExId:VerticalMerge
//ExSummary:Creates a table with two columns with cells merged vertically in the first column.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.Write("Text in merged cells.");
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.Write("Text in one cell");
builder.EndRow();
builder.InsertCell();
// This cell is vertically merged to the cell above and should be empty.
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.Write("Text in another cell");
builder.EndRow();
builder.EndTable();
//ExEnd
}
示例5: Run
public static void Run()
{
// ExStart:DocumentBuilderBuildTable
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithDocument();
// Initialize document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
// Insert a cell
builder.InsertCell();
// Use fixed column widths.
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
builder.EndRow();
// Insert a cell
builder.InsertCell();
// Apply new row formatting
builder.RowFormat.Height = 100;
builder.RowFormat.HeightRule = HeightRule.Exactly;
builder.CellFormat.Orientation = TextOrientation.Upward;
builder.Writeln("This is row 2 cell 1");
// Insert a cell
builder.InsertCell();
builder.CellFormat.Orientation = TextOrientation.Downward;
builder.Writeln("This is row 2 cell 2");
builder.EndRow();
builder.EndTable();
dataDir = dataDir + "DocumentBuilderBuildTable_out.doc";
doc.Save(dataDir);
// ExEnd:DocumentBuilderBuildTable
Console.WriteLine("\nTable build successfully using DocumentBuilder.\nFile saved at " + dataDir);
}
示例6: Main
static void Main(string[] args)
{
// Check for license and apply if exists
string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
if (File.Exists(licenseFile))
{
// Apply Aspose.Words API License
Aspose.Words.License license = new Aspose.Words.License();
// Place license file in Bin/Debug/ Folder
license.SetLicense("Aspose.Words.lic");
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Start building a the table.
builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, Cell 1 Content");
// Build the second cell
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content");
// End previous row and start new
builder.EndRow();
// Build the first cell of 2nd row
builder.InsertCell();
builder.Write("Row 2, Cell 1 Content");
builder.InsertCell();
builder.Write("Row 2, Cell 2 Content");
builder.EndRow();
// End the table
builder.EndTable();
Range range = doc.Sections[0].Range;
range.Delete();
String text = doc.Range.Text;
System.Console.WriteLine(text);
System.Console.ReadKey();
}
示例7: Run
public static void Run()
{
// ExStart:BookmarkTable
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithBookmarks();
// Create empty document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
// Insert a cell
builder.InsertCell();
// Start bookmark here after calling InsertCell
builder.StartBookmark("MyBookmark");
builder.Write("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
builder.EndRow();
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 2 cell 1");
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 2 cell 2");
builder.EndRow();
builder.EndTable();
// End of bookmark
builder.EndBookmark("MyBookmark");
dataDir = dataDir + "Bookmark.Table_out.doc";
doc.Save(dataDir);
// ExEnd:BookmarkTable
Console.WriteLine("\nTable bookmarked successfully.\nFile saved at " + dataDir);
}
示例8: DocumentBuilderSetRowFormatting
public void DocumentBuilderSetRowFormatting()
{
//ExStart
//ExFor:DocumentBuilder.RowFormat
//ExFor:RowFormat.Height
//ExFor:RowFormat.HeightRule
//ExFor:Table.LeftPadding
//ExFor:Table.RightPadding
//ExFor:Table.TopPadding
//ExFor:Table.BottomPadding
//ExId:DocumentBuilderSetRowFormatting
//ExSummary:Shows how to create a table that contains a single cell and apply row formatting.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
builder.InsertCell();
// Set the row formatting
RowFormat rowFormat = builder.RowFormat;
rowFormat.Height = 100;
rowFormat.HeightRule = HeightRule.Exactly;
// These formatting properties are set on the table and are applied to all rows in the table.
table.LeftPadding = 30;
table.RightPadding = 30;
table.TopPadding = 30;
table.BottomPadding = 30;
builder.Writeln("I'm a wonderful formatted row.");
builder.EndRow();
builder.EndTable();
//ExEnd
}
示例9: InsertTable
/// <summary>
/// Insert new table in the document
/// </summary>
private static void InsertTable(Document doc)
{
DocumentBuilder builder = new DocumentBuilder(doc);
//Start creating a new table
Table table = builder.StartTable();
//Insert Row 1 Cell 1
builder.InsertCell();
builder.Write("Date");
//Set width to fit the table contents
table.AutoFit(AutoFitBehavior.AutoFitToContents);
//Insert Row 1 Cell 2
builder.InsertCell();
builder.Write(" ");
builder.EndRow();
//Insert Row 2 Cell 1
builder.InsertCell();
builder.Write("Author");
//Insert Row 2 Cell 2
builder.InsertCell();
builder.Write(" ");
builder.EndRow();
builder.EndTable();
}
示例10: HorizontalMerge
public static void HorizontalMerge(string dataDir)
{
// ExStart:HorizontalMerge
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("Text in merged cells.");
builder.InsertCell();
// This cell is merged to the previous and should be empty.
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.EndRow();
builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("Text in one cell.");
builder.InsertCell();
builder.Write("Text in another cell.");
builder.EndRow();
builder.EndTable();
dataDir = dataDir + "Table.HorizontalMerge_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:HorizontalMerge
Console.WriteLine("\nTable created successfully with cells in the first row horizontally merged.\nFile saved at " + dataDir);
}
示例11: DocumentBuilderSetCellFormatting
public void DocumentBuilderSetCellFormatting()
{
//ExStart
//ExFor:DocumentBuilder.CellFormat
//ExFor:CellFormat.Width
//ExFor:CellFormat.LeftPadding
//ExFor:CellFormat.RightPadding
//ExFor:CellFormat.TopPadding
//ExFor:CellFormat.BottomPadding
//ExFor:DocumentBuilder.StartTable
//ExFor:DocumentBuilder.EndTable
//ExId:DocumentBuilderSetCellFormatting
//ExSummary:Shows how to create a table that contains a single formatted cell.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.StartTable();
builder.InsertCell();
// Set the cell formatting
CellFormat cellFormat = builder.CellFormat;
cellFormat.Width = 250;
cellFormat.LeftPadding = 30;
cellFormat.RightPadding = 30;
cellFormat.TopPadding = 30;
cellFormat.BottomPadding = 30;
builder.Writeln("I'm a wonderful formatted cell.");
builder.EndRow();
builder.EndTable();
//ExEnd
}
示例12: btnExportToWord_Click
protected void btnExportToWord_Click(object sender, EventArgs e)
{
Int16 PK_iChuyengiaID = Int16.Parse(btnExportToWord.CommandArgument);
ChuyengiaEntity oChuyengia = ChuyengiaBRL.GetOne(PK_iChuyengiaID);
TochucchungnhanEntity oTochuc = TochucchungnhanBRL.GetOne(oChuyengia.FK_iTochucchungnhanID);
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
builder.PageSetup.VerticalAlignment = PageVerticalAlignment.Top;
builder.Font.Size = 12;
//------------------------------
builder.StartTable(); //Tạo bảng
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 200;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.InsertCell(); //Ô trái
builder.Font.Bold = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Writeln("BỘ NÔNG NGHIỆP VÀ PTNT");
builder.Writeln(oTochuc.sCoquancap);
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 250;
builder.InsertCell(); //Ô phải
builder.Font.Bold = false;
builder.Writeln("CỘNG HOÀ XÃ HỘI CHỦ NGHĨA VIỆT NAM");
builder.Writeln("Độc lập - Tự do- Hạnh phúc");
builder.InsertHtml("<hr width='40%' />");
builder.EndRow(); //Kết thúc hàng
//-------------------------------
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 410;
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.InsertImage(oChuyengia.imAnh, 100.0, 134.0);
builder.EndRow();
//-------------------------------
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 500;
builder.InsertCell();
builder.Font.Bold = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Writeln("THẺ CHUYÊN GIA ĐÁNH GIÁ VietGAP");
builder.EndRow();
//-------------------------------
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 500;
builder.InsertCell();
builder.Font.Bold = false;
builder.ParagraphFormat.LineSpacing = 10.0;
builder.Writeln("\t\tHọ và tên: " + oChuyengia.sHoten);
builder.Writeln("\t\tNăm sinh: " + "");
builder.Writeln("\t\tĐơn vị công tác: " + oTochuc.sTochucchungnhan);
builder.Writeln("\t\tLĩnh vực đánh giá: " + "");
builder.Write("\t\tMã số: ");
builder.Font.Bold = true;
builder.Writeln(oChuyengia.sMaso);
builder.EndRow();
//------------------------------
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 220;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.InsertCell(); //Ô trái
builder.RowFormat.AllowAutoFit = false;
builder.CellFormat.Width = 220;
builder.InsertCell(); //Ô phải
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Writeln("... , ngày ... tháng ... năm 20..");
builder.Font.Bold = true;
builder.Writeln("Thủ trưởng đơn vị");
builder.Font.Bold = false;
builder.Font.Italic = true;
builder.Writeln("( Ký tên, đóng dấu)");
builder.EndRow(); //Kết thúc hàng
builder.EndTable(); //Kết thúc bảng
doc.Save("Thechuyengia_" + oChuyengia.sMaso + ".doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);
//Disponse
oChuyengia = null;
oTochuc = null;
}
示例13: btnExToWord_Click
protected void btnExToWord_Click(object sender, EventArgs e)
{
if (Session["userID"] == null) return;
iUserID = Convert.ToInt32(Session["userID"].ToString());
List<TochucchungnhanTaikhoanEntity> lstTochucTaikhoan = TochucchungnhanTaikhoanBRL.GetByFK_iTaikhoanID(iUserID);
int iTochucID = 0;
if (lstTochucTaikhoan.Count > 0)
iTochucID = lstTochucTaikhoan[0].FK_iTochucchungnhanID;
oTochuc = TochucchungnhanBRL.GetOne(iTochucID);
//-----------
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
builder.PageSetup.PaperSize = PaperSize.A4;
builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
builder.PageSetup.VerticalAlignment = PageVerticalAlignment.Top;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Font.Bold = true;
builder.Font.Italic = false;
builder.Font.Size = 14;
builder.Writeln("CỘNG HOÀ XÃ HỘI CHỦ NGHĨA VIỆT NAM");
builder.Writeln("Độc lập - Tự do - Hạnh phúc");
builder.Writeln("-------");
builder.Writeln("");
builder.Font.Bold = false;
builder.Font.Italic = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Writeln("……, ngày ... tháng … năm 20…");
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Font.Bold = true;
builder.Font.Italic = false;
builder.Writeln("ĐƠN ĐĂNG KÝ");
builder.Font.Bold = false;
builder.Writeln("HOẠT ĐỘNG CHỨNG NHẬN VIETGAP");
builder.Font.Bold = true;
builder.Write("Kính gửi: ");
builder.Font.Bold = false;
builder.Writeln("Cơ quan công nhận Tổ chức Chứng nhận");
builder.Writeln("");
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.Writeln("- Tên tổ chức: " + oTochuc.sTochucchungnhan);
builder.Writeln("- Địa chỉ liên lạc: " + oTochuc.sDiachi);
builder.Writeln("- Điện thoại: " + oTochuc.sSodienthoai + " Fax: " + oTochuc.sFax + " E-mail: " + oTochuc.sEmail);
builder.Write("- Quyết định thành lập (nếu có) hoặc Giấy đăng ký kinh doanh số "+ oTochuc.sSodangkykinhdoanh +" do Cơ ");
DateTime dt = DateTime.Parse(oTochuc.dNgaycapdangkykinhdoanh.ToString());
String sNgaycap = String.Format("{0:dd/MM/yyyy}", dt);
builder.Writeln("quan cấp: " + oTochuc.sCoquancap + " cấp ngày " + sNgaycap + " tại " + oTochuc.sNoicapdangkykinhdoanh);
builder.Writeln("Sau khi nghiên cứu các điều kiện hoạt động chứng nhận VietGAP theo Thông tư số /2011/TT-BNNPTNT ngày tháng năm 2011 của Bộ trưởng Bộ Nông nghiệp và Phát triển nông thôn ban hành Thông tư chứng nhận thực hành Nuôi trồng thuỷ sản tốt (VietGAP) chúng tôi nhận thấy có đủ các điều kiện để hoạt động chứng nhận VietGAP cho " + oTochuc.sTochucchungnhan);
builder.Writeln("Hồ sơ kèm theo: ");
builder.Writeln("");
List<DangkyHoatdongchungnhanEntity> lstDangky = DangkyHoatdongchungnhanBRL.GetByFK_iTochucchungnhanID(iTochucID);
if (lstDangky.Count > 0)
{
List<HosokemtheoTochucchungnhanEntity> lstHoso = HosokemtheoTochucchungnhanBRL.GetByFK_iDangkyChungnhanVietGapID(lstDangky[0].PK_iDangkyChungnhanVietGapID);
if (lstHoso.Count > 0)
{
foreach (HosokemtheoTochucchungnhanEntity et in lstHoso)
{
builder.Writeln("- " + GiaytoBRL.GetOne(et.FK_iGiaytoID).sTengiayto);
}
}
}
builder.Write("Đề nghị ");
builder.Font.Italic = true;
builder.Font.Bold = true;
builder.Write("Cơ quan công nhận ");
builder.Font.Italic = false;
builder.Font.Bold = false;
builder.Write("Tổ chức Chứng nhận xem xét để công nhận (tên tổ");
builder.Writeln("chức) được hoạt động chứng nhận VietGAP cho: ");
builder.Writeln("\t-\tĐăng ký công nhận lần đầu:");
builder.Writeln("\t-\tĐăng ký công nhận lại:");
builder.Writeln("\t-\tĐăng ký mở rộng hoạt động chứng nhận:");
builder.Writeln("Chúng tôi xin cam kết thực hiện đúng các quy định về hoạt động chứng nhận VietGAP./.");
//-------Table
Aspose.Words.Table table = builder.StartTable();
builder.CellFormat.Width = 260;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.InsertCell();
builder.InsertCell();
builder.Font.Bold = true;
builder.Font.Italic = false;
builder.Writeln("Đại diện Tổ chức ...");
builder.Font.Bold = false;
builder.Font.Italic = true;
builder.Writeln("(Ký tên, đóng dấu)");
builder.EndRow();
builder.EndTable();
//--------end table
/*
* Lưu file
*/
doc.Save("DonDangKy_" + oTochuc.PK_iTochucchungnhanID + ".doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);
}
示例14: InsertTable
public void InsertTable()
{
//ExStart
//ExFor:DocumentBuilder
//ExFor:DocumentBuilder.StartTable
//ExFor:DocumentBuilder.InsertCell
//ExFor:DocumentBuilder.EndRow
//ExFor:DocumentBuilder.EndTable
//ExFor:DocumentBuilder.CellFormat
//ExFor:DocumentBuilder.RowFormat
//ExFor:CellFormat
//ExFor:CellFormat.Width
//ExFor:CellFormat.VerticalAlignment
//ExFor:CellFormat.Shading
//ExFor.CellFormat.Orientation
//ExFor:RowFormat
//ExFor:RowFormat.HeightRule
//ExFor:RowFormat.Height
//ExFor:RowFormat.Borders
//ExFor:Shading.BackgroundPatternColor
//ExFor:Shading.ClearFormatting
//ExSummary:Shows how to build a nice bordered table.
DocumentBuilder builder = new DocumentBuilder();
// Start building a table.
builder.StartTable();
// Set the appropriate paragraph, cell, and row formatting. The formatting properties are preserved
// until they are explicitly modified so there's no need to set them for each row or cell.
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.Width = 300;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.CellFormat.Shading.BackgroundPatternColor = Color.GreenYellow;
builder.RowFormat.HeightRule = HeightRule.Exactly;
builder.RowFormat.Height = 50;
builder.RowFormat.Borders.LineStyle = LineStyle.Engrave3D;
builder.RowFormat.Borders.Color = Color.Orange;
builder.InsertCell();
builder.Write("Row 1, Col 1");
builder.InsertCell();
builder.Write("Row 1, Col 2");
builder.EndRow();
// Remove the shading (clear background).
builder.CellFormat.Shading.ClearFormatting();
builder.InsertCell();
builder.Write("Row 2, Col 1");
builder.InsertCell();
builder.Write("Row 2, Col 2");
builder.EndRow();
builder.InsertCell();
// Make the row height bigger so that a vertically oriented text could fit into cells.
builder.RowFormat.Height = 150;
builder.CellFormat.Orientation = TextOrientation.Upward;
builder.Write("Row 3, Col 1");
builder.InsertCell();
builder.CellFormat.Orientation = TextOrientation.Downward;
builder.Write("Row 3, Col 2");
builder.EndRow();
builder.EndTable();
builder.Document.Save(ExDir + "DocumentBuilder.InsertTable Out.doc");
//ExEnd
}
示例15: Main
static void Main(string[] args)
{
//----------------------------------------------------
// NPOI
//----------------------------------------------------
//XWPFDocument doc = new XWPFDocument();
//XWPFParagraph para = doc.CreateParagraph();
//XWPFRun r0 = para.CreateRun();
//r0.SetText("Title1");
//para.BorderTop = Borders.THICK;
//para.FillBackgroundColor = "EEEEEE";
//para.FillPattern = NPOI.OpenXmlFormats.Wordprocessing.ST_Shd.diagStripe;
//XWPFTable table = doc.CreateTable(3, 3);
//table.GetRow(1).GetCell(1).SetText("EXAMPLE OF TABLE");
//XWPFTableCell c1 = table.GetRow(0).GetCell(0);
//XWPFParagraph p1 = c1.AddParagraph(); //don't use doc.CreateParagraph
//XWPFRun r1 = p1.CreateRun();
//r1.SetText("The quick brown fox");
//r1.SetBold(true);
//r1.FontFamily = "Courier";
//r1.SetUnderline(UnderlinePatterns.DotDotDash);
//r1.SetTextPosition(100);
//c1.SetColor("FF0000");
//table.GetRow(2).GetCell(2).SetText("only text");
//FileStream out1 = new FileStream("simpleTable.docx", FileMode.Create);
//doc.Write(out1);
//out1.Close();
//----------------------------------------------------
// Aspose.Words
//----------------------------------------------------
// Check for license and apply if exists
string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
if (File.Exists(licenseFile))
{
// Apply Aspose.Words API License
Aspose.Words.License license = new Aspose.Words.License();
// Place license file in Bin/Debug/ Folder
license.SetLicense("Aspose.Words.lic");
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ParagraphFormat.Borders.Top.LineStyle = LineStyle.Thick;
builder.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#EEEEEE");
builder.ParagraphFormat.Shading.Texture = TextureIndex.TextureDarkDiagonalUp;
builder.Writeln("Title1");
builder.ParagraphFormat.ClearFormatting();
builder.InsertBreak(BreakType.ParagraphBreak);
// We call this method to start building the table.
builder.StartTable();
builder.InsertCell();
builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
builder.Font.Position = 100;
builder.Font.Name = "Courier";
builder.Font.Bold = true;
builder.Font.Underline = Underline.DotDotDash;
builder.Write("The quick brown fox");
builder.InsertCell();
builder.Font.ClearFormatting();
builder.CellFormat.ClearFormatting();
builder.InsertCell();
builder.EndRow();
builder.InsertCell();
builder.InsertCell();
builder.Write("EXAMPLE OF TABLE");
builder.InsertCell();
builder.EndRow();
builder.InsertCell();
builder.InsertCell();
builder.InsertCell();
builder.Write("only text");
builder.EndRow();
// Signal that we have finished building the table.
builder.EndTable();
doc.Save("simpleTable.docx");
}