This is a migrated thread and some comments may be shown as answers.

Import Table from RadSpreadsheet

3 Answers 116 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Torsten
Top achievements
Rank 1
Torsten asked on 11 Nov 2014, 12:32 PM
Is it possible to import a Table from RadSpreadsheet like MS Word form MS Excel?

Until now it seems to me, that I only can import it as Plaintext. So the backgroundcolor, etc. goes lost.

Thanks in advance.
Torsten

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Demirev
Telerik team
answered on 13 Nov 2014, 03:48 PM
Hi Torsten,

I have prepared a sample project showing how you can achieve the desired behaviour. You can find it attached.

Regards,
Nikolay Demirev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Torsten
Top achievements
Rank 1
answered on 21 Nov 2014, 12:25 PM
Thanks for the sample project that helped me a lot.^^

Is it also possible to set the width of the columns? and the width of the table?

I' ve tired this Method but it says its not for "Telerik.Windows.Documents.Flow.Model.Table"
radRichTextBox.ChangeTableGridColumnWidth(table , myCol, new Telerik.Windows.Documents.Model.TableWidthUnit(myWidth));

Also i found the table layouttype. I set it to FixedWidth but where can I set the width?

Regards, Torsten

0
Nikolay Demirev
Telerik team
answered on 25 Nov 2014, 12:11 PM
Hello Torsten,

Here is the modified code from the example which copies the content of the current cell so it copies the cell width too:

Worksheet worksheet = this.radSpreadshet.ActiveWorksheet;
TableCell wordCell = table.Rows[row].Cells[col];
CellSelection excelCell = worksheet.Cells[fromIndex.RowIndex + row, fromIndex.ColumnIndex + col];
 
wordCell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, worksheet.Columns[fromIndex.ColumnIndex + col].GetWidth().Value.Value);
 
PatternFill fill = excelCell.GetFill().Value as PatternFill;
if (fill != null)
{
    wordCell.Properties.BackgroundColor.LocalValue = fill.PatternColor;
}
 
wordCell.Borders = this.ExcelBordersToWordBorders(excelCell.GetBorders());
CellValueFormat numberFormat = excelCell.GetFormat().Value;
Paragraph paragraph = wordCell.Blocks.AddParagraph();
paragraph.Inlines.AddRun(excelCell.GetValue().Value.GetResultValueAsString(numberFormat));
paragraph.TextAlignment = this.radHorizontalAlignmentToAlignment[excelCell.GetHorizontalAlignment().Value];


Regards,
Nikolay Demirev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RichTextBox
Asked by
Torsten
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Torsten
Top achievements
Rank 1
Share this question
or