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

Open Office document in RichTextBox

3 Answers 81 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Chirag
Top achievements
Rank 1
Chirag asked on 16 Feb 2013, 08:58 AM
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 
 
 

3 Answers, 1 is accepted

Sort by
0
pedrotti
Top achievements
Rank 1
answered on 29 Oct 2013, 07:55 AM
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
0
Petya
Telerik team
answered on 30 Oct 2013, 04:15 PM
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 >>
0
Chirag
Top achievements
Rank 1
answered on 31 Oct 2013, 05:49 AM
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");               
}

Tags
RichTextBox
Asked by
Chirag
Top achievements
Rank 1
Answers by
pedrotti
Top achievements
Rank 1
Petya
Telerik team
Chirag
Top achievements
Rank 1
Share this question
or