Import Table from RadSpreadsheet

4 posts, 1 answers
  1. Torsten
    Torsten avatar
    2 posts
    Member since:
    Oct 2014

    Posted 11 Nov 2014 Link to this post

    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
  2. Answer
    Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 13 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Torsten
    Torsten avatar
    2 posts
    Member since:
    Oct 2014

    Posted 21 Nov 2014 in reply to Nikolay Demirev Link to this post

    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

  5. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 25 Nov 2014 Link to this post

    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.

     
Back to Top