Borders I am creating with RadFlowDocumentEditor are not displayed in Radrichtextbox, to demonstrate here is my test code, I am using Telerik UI for WPF R2 2019.
Attached is the file, also how it is displayed in Word and the how it is displayed in the RadRichTextBox inside my application.
using
System.Windows;
using
System.Windows.Controls;
using
Telerik.Windows.Controls;
using
Telerik.Windows.Documents.FormatProviders.Html;
using
System.Linq;
using
System;
using
System.IO;
using
Telerik.Windows.Documents.Flow.Model;
using
Telerik.Windows.Documents.Flow.Model.Editing;
using
Telerik.Windows.Documents.Flow.Model.Styles;
using
Telerik.Windows.Documents.Spreadsheet.Model;
public
void
CreateCell(RadFlowDocumentEditor documentEditor, Table table,
int
row,
int
column,
string
text, FontWeight fw,
float
Width, Alignment alignment,
double
fs = 0)
{
while
(table.Rows[row].Cells.Count < (column + 1))
{
table.Rows[row].Cells.AddTableCell();
}
Paragraph newPara = table.Rows[row].Cells[column].Blocks.AddParagraph();
table.Rows[row].Cells[column].PreferredWidth =
new
TableWidthUnit(Width);
table.Rows[row].Cells[column].Padding =
new
Telerik.Windows.Documents.Primitives.Padding(2);
newPara.TextAlignment = alignment;
documentEditor.MoveToParagraphStart(newPara);
var line = documentEditor.InsertText(text);
line.FontWeight = fw;
if
(fs > 0) line.FontSize = fs;
}
private
void
radButtonTest_Click(
object
sender, RoutedEventArgs e)
{
//produce test doc
Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider =
new
Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
RadFlowDocument document =
new
RadFlowDocument();
RadFlowDocumentEditor documentEditor =
new
RadFlowDocumentEditor(document);
//create table
Table table = documentEditor.InsertTable(1, 3);
//header
double
fsText = Telerik.Windows.Documents.Model.Unit.PointToDip(10);
var row = 0;
CreateCell(documentEditor,table, row, 0,
"Time"
, FontWeights.Bold, 80, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 1,
"Type"
, FontWeights.Bold, 200, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 2,
"Location"
, FontWeights.Bold, 230, Alignment.Left, fsText);
table.Rows[row].Cells[0].Shading.BackgroundColor =
new
ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1, 0.5);
table.Rows[row].Cells[1].Shading.BackgroundColor =
new
ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1);
table.Rows[row].Cells[2].Shading.BackgroundColor =
new
ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1, 0.9);
//add rows
table.Rows.AddTableRow();
row++;
CreateCell(documentEditor, table, row, 0, DateTime.Now.ToString(
"HH:mm:ss"
), FontWeights.Normal, 80, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 1,
"Value "
+ row.ToString(), FontWeights.Normal, 200, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 2,
"Loc "
+ row.ToString(), FontWeights.Normal, 230, Alignment.Left, fsText);
table.Rows[row].Cells[0].Borders =
new
TableCellBorders(
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
table.Rows[row].Cells[1].Borders =
new
TableCellBorders(
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
table.Rows[row].Cells[2].Borders =
new
TableCellBorders(
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
,
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
table.Rows.AddTableRow();
row++;
CreateCell(documentEditor, table, row, 0, DateTime.Now.ToString(
"HH:mm:ss"
), FontWeights.Normal, 80, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 1,
"Value "
+ row.ToString(), FontWeights.Normal, 200, Alignment.Left, fsText);
CreateCell(documentEditor, table, row, 2,
"Loc "
+ row.ToString(), FontWeights.Normal, 230, Alignment.Left, fsText);
table.Borders =
new
TableBorders(
new
Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Single));
//save test file
using
(Stream output =
new
FileStream(@
"c:\temp\testdoc.docx"
, FileMode.OpenOrCreate))
{
provider.Export(document, output);
}
}