Open Office document in RichTextBox

4 posts, 0 answers
  1. Chirag
    Chirag avatar
    37 posts
    Member since:
    May 2011

    Posted 16 Feb 2013 Link to this post

    Hi to all 

    i have some  office document in database as a binary. i want to open that in to richtextbox specialy .docx files  no need to open from application menu , load data directly from binary  or any other method to open in richtexbox.
    how could i rich this requirment 
    Please help me out 

    thanks in advance 
     
     
  2. LEVEFAUDE
    LEVEFAUDE avatar
    39 posts
    Member since:
    Apr 2011

    Posted 29 Oct 2013 Link to this post

    Hello

    Sorryn I can't help you and I hope you found a solution

    BUT, I have to make 'mailings' with an IIE application / SQL database / Open Office or Word Office
    I have to keep document as binary in SQL

    Maybe, you do the same ? or a bit or this ?

    Can you give me some help to begin (source code, for example...........)

    A lot a thank you

    Anne
  3. DevCraft banner
  4. Petya
    Admin
    Petya avatar
    975 posts

    Posted 30 Oct 2013 Link to this post

    Hello,

    RadRichtextBox provides import/export to several formats, including DOCX. In data-bound scenario you can use the data providers which wrap the functionality of the format providers. You can check the demo here to see how this works.

    Let me know if you have additional questions.

    Regards,
    Petya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Chirag
    Chirag avatar
    37 posts
    Member since:
    May 2011

    Posted 31 Oct 2013 Link to this post

    Hello Anne


    I have done with Following Code may be help you for docx files

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <telerik:RadRichTextBox Grid.Row="0" x:Name="RRTDocViewer"  AllowDrop="True" IsSpellCheckingEnabled="False" />
        <telerik:RadRichTextBoxStatusBar Grid.Row="1" AssociatedRichTextBox="{Binding ElementName=RRTDocViewer, Mode=OneTime}"/>
    </Grid>

    in code behind 
    public byte[] FileData
    try
    {
        MemoryStream outputStream = new MemoryStream(FileData);
        RadDocument Rdoc;
        IDocumentFormatProvider provider = null;
     
        if (FileExtension.ToLower().Contains("docx") || FileExtension.ToLower().Contains("txt"))
        {
            provider = DocumentFormatProvidersManager.GetProviderByExtension(FileExtension);
        }
        else
        {
            provider = DocumentFormatProvidersManager.GetProviderByExtension(".txt");
        }
        if (provider != null)
        {
            Rdoc = provider.Import(outputStream);
        }
        else
        {
            GrdDocx.Visibility = System.Windows.Visibility.Collapsed;
     
            MessageBox.Show("Unable to open file");                   
            return;
        }
        RRTDocViewer.Document = Rdoc;
    }
    catch
    {  
        GrdDocx.Visibility = System.Windows.Visibility.Collapsed;
        MessageBox.Show("Unable to open file");               
    }

Back to Top