//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;
namespace DsWordWeb.Demos
{
// Demo of all built-in table styles
public class BuiltInTableStyles
{
public GcWordDocument CreateDocx()
{
var rows = 3;
var cols = 4;
var doc = new GcWordDocument();
var pars = doc.Body.Paragraphs;
pars.Add("Demo of All Built-in Table Styles", doc.Styles[BuiltInStyleId.Title]);
foreach (BuiltInStyleId id in Enum.GetValues(typeof(BuiltInStyleId)))
{
if (id == BuiltInStyleId.User)
continue;
var style = doc.Styles[id];
if (style.Type != StyleType.Table)
continue;
pars.Add($"The following table is formatted using style '{style.Name}':");
var table = doc.Body.Tables.Add(cols, rows, style);
for (int row = 0; row < rows; ++row)
for (int col = 0; col < cols; ++col)
table.Rows[row].Cells[col].GetRange().Paragraphs.First.GetRange().Runs.Add($"Cell ({row},{col})");
}
// Done:
return doc;
}
}
}