本文整理汇总了C#中DocumentBuilder.InsertCell方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.InsertCell方法的具体用法?C# DocumentBuilder.InsertCell怎么用?C# DocumentBuilder.InsertCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.InsertCell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.
Aspose.Words.Document doc = new Aspose.Words.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
}
示例2: 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
}
示例3: AutoFitToPageWidth
/// <summary>
/// Shows how to set a table to auto fit to 50% of the page width.
/// </summary>
private static void AutoFitToPageWidth(string dataDir)
{
// ExStart:AutoFitToPageWidth
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table with a width that takes up half the page width.
Table table = builder.StartTable();
// Insert a few cells
builder.InsertCell();
table.PreferredWidth = PreferredWidth.FromPercent(50);
builder.Writeln("Cell #1");
builder.InsertCell();
builder.Writeln("Cell #2");
builder.InsertCell();
builder.Writeln("Cell #3");
dataDir = dataDir + "Table.PreferredWidth_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:AutoFitToPageWidth
Console.WriteLine("\nTable autofit successfully to 50% of the page width.\nFile saved at " + dataDir);
}
示例4: 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");
}
示例5: VerticalMerge
// ExEnd:PrintCellMergeType
public static void VerticalMerge( string dataDir)
{
// ExStart:VerticalMerge
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();
dataDir = dataDir + "Table.VerticalMerge_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:VerticalMerge
Console.WriteLine("\nTable created successfully with two columns with cells merged vertically in the first column.\nFile saved at " + dataDir);
}
示例6: 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);
}
示例7: SetPreferredWidthSettings
/// <summary>
/// Shows how to set the different preferred width settings.
/// </summary>
private static void SetPreferredWidthSettings(string dataDir)
{
// ExStart:SetPreferredWidthSettings
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table row made up of three cells which have different preferred widths.
Table table = builder.StartTable();
// Insert an absolute sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
builder.Writeln("Cell at 40 points width");
// Insert a relative (percent) sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
builder.Writeln("Cell at 20% width");
// Insert a auto sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
builder.Writeln("Cell automatically sized. The size of this cell is calculated from the table preferred width.");
builder.Writeln("In this case the cell will fill up the rest of the available space.");
dataDir = dataDir + "Table.CellPreferredWidths_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:SetPreferredWidthSettings
Console.WriteLine("\nDifferent preferred width settings set successfully.\nFile saved at " + dataDir);
}
示例8: 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);
Table table = builder.StartTable();
builder.InsertCell();
// Set the borders for the entire table.
table.SetBorders(LineStyle.Single, 2.0, Color.Black);
// Set the cell shading for this cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
builder.Writeln("Cell #1");
builder.InsertCell();
// Specify a different cell shading for the second cell.
builder.CellFormat.Shading.BackgroundPatternColor=Color.Blue;
builder.Writeln("Cell #2");
// End this row.
builder.EndRow();
// Clear the cell formatting from previous operations.
builder.CellFormat.ClearFormatting();
// Create the second row.
builder.InsertCell();
// Create larger borders for the first cell of this row. This will be different
// compared to the borders set for the table.
builder.CellFormat.Borders.Left.LineWidth=4.0;
builder.CellFormat.Borders.Right.LineWidth=4.0;
builder.CellFormat.Borders.Top.LineWidth=4.0;
builder.CellFormat.Borders.Bottom.LineWidth=4.0;
builder.Writeln("Cell #3");
builder.InsertCell();
// Clear the cell formatting from the previous cell.
builder.CellFormat.ClearFormatting();
builder.Writeln("Cell #4");
doc.Save("Format Table in Document.doc");
}
示例9: 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);
}
示例10: SetTableCellFormatting
public static void SetTableCellFormatting(string dataDir)
{
// ExStart:DocumentBuilderSetTableCellFormatting
Document doc = new 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();
dataDir = dataDir + "DocumentBuilderSetTableCellFormatting_out.doc";
doc.Save(dataDir);
// ExEnd:DocumentBuilderSetTableCellFormatting
Console.WriteLine("\nTable cell formatting using DocumentBuilder set successfully.\nFile saved at " + dataDir);
}
示例11: 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();
}
示例12: 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);
}
示例13: Main
static void Main(string[] args)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
builder.InsertCell();
// Set the borders for the entire table.
table.SetBorders(LineStyle.Single, 2.0, Color.Black);
// Set the cell shading for this cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
builder.Writeln("Cell #1");
builder.InsertCell();
// Specify a different cell shading for the second cell.
builder.CellFormat.Shading.BackgroundPatternColor=Color.Blue;
builder.Writeln("Cell #2");
// End this row.
builder.EndRow();
// Clear the cell formatting from previous operations.
builder.CellFormat.ClearFormatting();
// Create the second row.
builder.InsertCell();
// Create larger borders for the first cell of this row. This will be different
// compared to the borders set for the table.
builder.CellFormat.Borders.Left.LineWidth=4.0;
builder.CellFormat.Borders.Right.LineWidth=4.0;
builder.CellFormat.Borders.Top.LineWidth=4.0;
builder.CellFormat.Borders.Bottom.LineWidth=4.0;
builder.Writeln("Cell #3");
builder.InsertCell();
// Clear the cell formatting from the previous cell.
builder.CellFormat.ClearFormatting();
builder.Writeln("Cell #4");
doc.Save("data/Format Table in Document.doc");
}
示例14: Run
public static void Run()
{
// ExStart:RepeatRowsOnSubsequentPages
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithTables();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
builder.RowFormat.HeadingFormat = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.Width = 100;
builder.InsertCell();
builder.Writeln("Heading row 1");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Heading row 2");
builder.EndRow();
builder.CellFormat.Width = 50;
builder.ParagraphFormat.ClearFormatting();
// Insert some content so the table is long enough to continue onto the next page.
for (int i = 0; i < 50; i++)
{
builder.InsertCell();
builder.RowFormat.HeadingFormat = false;
builder.Write("Column 1 Text");
builder.InsertCell();
builder.Write("Column 2 Text");
builder.EndRow();
}
dataDir = dataDir + "Table.HeadingRow_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:RepeatRowsOnSubsequentPages
Console.WriteLine("\nTable build successfully which include heading rows that repeat on subsequent pages..\nFile saved at " + dataDir);
}
示例15: BuildTableWithStyle
/// <summary>
/// Shows how to build a new table with a table style applied.
/// </summary>
private static void BuildTableWithStyle(string dataDir)
{
// ExStart:BuildTableWithStyle
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
// We must insert at least one row first before setting any table formatting.
builder.InsertCell();
// Set the table style used based of the unique style identifier.
// Note that not all table styles are available when saving as .doc format.
table.StyleIdentifier = StyleIdentifier.MediumShading1Accent1;
// Apply which features should be formatted by the style.
table.StyleOptions = TableStyleOptions.FirstColumn | TableStyleOptions.RowBands | TableStyleOptions.FirstRow;
table.AutoFit(AutoFitBehavior.AutoFitToContents);
// Continue with building the table as normal.
builder.Writeln("Item");
builder.CellFormat.RightPadding = 40;
builder.InsertCell();
builder.Writeln("Quantity (kg)");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Apples");
builder.InsertCell();
builder.Writeln("20");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Bananas");
builder.InsertCell();
builder.Writeln("40");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Carrots");
builder.InsertCell();
builder.Writeln("50");
builder.EndRow();
dataDir = dataDir + "DocumentBuilder.SetTableStyle_out.docx";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:BuildTableWithStyle
Console.WriteLine("\nTable created successfully with table style.\nFile saved at " + dataDir);
}