6 Answers, 1 is accepted
0
0
Dan
Top achievements
Rank 1
answered on 09 Jul 2015, 01:33 PM
Thank doesn't seem to help. The scenario is a large table that needs to be a bit squeezed onto the page. Data with spaces in them should typically be wrapped first.
Example of the problem with or without TableLayoutType.AutoFit set:
0
Dan
Top achievements
Rank 1
answered on 09 Jul 2015, 01:34 PM
Sorry - here is the attachment
0
Hello Dan,
I can suggest you to measure the text you want to set to a cell and then set the cell preferred width to the width of the text content. This way the width of the columns you want will be enough to show their values without the need to wrap the text. This can be done by finding the max width of the cells of the column and set the widths to the found max value. The following code snippet will help you achieve what you want:
I hope this works for you.
Regards,
Nikolay Demirev
Telerik
I can suggest you to measure the text you want to set to a cell and then set the cell preferred width to the width of the text content. This way the width of the columns you want will be enough to show their values without the need to wrap the text. This can be done by finding the max width of the cells of the column and set the widths to the found max value. The following code snippet will help you achieve what you want:
var table = new Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table();
var row = table.Rows.AddTableRow();
var cell = row.Cells.AddTableCell();
var block = cell.Blocks.AddBlock();
block.InsertText("1234");
cell.PreferredWidth = block.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)).Width;
I hope this works for you.
Regards,
Nikolay Demirev
Telerik
0
Dina
Top achievements
Rank 1
answered on 01 May 2017, 12:35 AM
It does not. Here you just shrink text. But how to prevent telerik from splitting words?
like
| Long text in Spread |
| sheet |
need to be
| Long text in |
| Spreadsheet |
0
Hello Dima,
Words should be split only when the word is too long to fit in the available cell width. However, if the word width is smaller than the cell width and the word in not fitting in the current line, then the whole word should be moved to the next line. We have tried to reproduce the mentioned issue with the following code but without success.
You may see the attached PDF file which is the result from exporting the above-generated RadFixedDocument.
Could you modify the above code so that it reproduces the mentioned issue?
Regards,
Deyan
Telerik by Progress
Words should be split only when the word is too long to fit in the available cell width. However, if the word width is smaller than the cell width and the word in not fitting in the current line, then the whole word should be moved to the next line. We have tried to reproduce the mentioned issue with the following code but without success.
public
RadFixedDocument CreateDocument()
{
RadFixedDocument document =
new
RadFixedDocument();
FixedContentEditor editor =
new
FixedContentEditor(document.Pages.AddPage());
Block word =
new
Block();
word.InsertText(
"Spreadsheet"
);
double
wordWidth = word.Measure().Width;
Table table =
new
Table();
table.DefaultCellProperties.Borders =
new
TableCellBorders(
new
Border(),
new
Border(),
new
Border(),
new
Border());
Block block = table.Rows.AddTableRow().Cells.AddTableCell().Blocks.AddBlock();
block.InsertText(
"Long text in Spreadsheet"
);
Size size = block.Measure();
editor.DrawTable(table, size.Width - wordWidth / 2);
return
document;
}
You may see the attached PDF file which is the result from exporting the above-generated RadFixedDocument.
Could you modify the above code so that it reproduces the mentioned issue?
Regards,
Deyan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.