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

Cannot open any DOCX file

5 Answers 123 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 10 Jan 2013, 07:37 PM
If I open any DOCX file, I get an error saying the file is locked and cannot be opened.  This is definitely not true.

I then pulled Telerik source code and ran.  I found that the error is in the Telerik.Windows.Documents.dll file.  The error is in Paragraph.cs.  The error is at line 409.  As you can see by the photo, the Levels only contains one item, yet it's trying to reference Item[1] which would be impossible.  Should be Item[0].

I can attach a DOCX file if no one else has this issue.

5 Answers, 1 is accepted

Sort by
0
Accepted
Mihail
Telerik team
answered on 14 Jan 2013, 10:44 AM
Hello Paul,
 
The problem is that the paragraph is associated with a level of the list style that is missing. The question is why this level is missing and if the paragraph should be connected to this level.

We would appreciate it if you could open a support ticket and attach the file in question, so that we can investigate the case. It would also help if you could give us more information on how you created the file.

Looking forward to your reply.

Kind regards,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tuo
Top achievements
Rank 1
answered on 21 Jan 2013, 02:25 PM
Hello Telerik,
I had the same problem with opening docx file containing custom list style.
  Add custom style:
      Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles.Add("CustomListStyle", customListStyle);
 Using custom style:
      customDocList= new Telerik.Windows.Documents.Lists.DocumentList(Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles("CustomListStyle"), doc)
      customDocList.Add(paragraph, level)

  Export document to Docx
       FormatProviders.OpenXml.Docx.DocxFormatProvider docxFormatter;
       docxFormatter.Export(doc);
 After exporting to docx, then it will have  that problem.

Best,
Tuo
    
0
Mihail
Telerik team
answered on 23 Jan 2013, 02:01 PM
Hello Tou,

The issue you have encountered is related to the way you add custom styles. There is a help article on the subject which will be useful for you. If you follow the approach for registering and applying a custom style outlined there, there must not be any problems with the export.

Greetings,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tuo
Top achievements
Rank 1
answered on 28 Jan 2013, 03:13 PM
Hi Mihail,
       I Copied the example provided here to test the Custom ListStyle by adding it programmatically.
       The way I did is as follows:
ListStyle myListStyle = CustomListStyle.CreateCustomListStyle();  // copy the code from the example to generate ListLevels
ListStyle customListStyle = this.richTextBox.Document.AddCustomListStyle(myListStyle);

      The problem is that the ListLevels is empty in the returned "customListStyle", .
      Is there any point missed? Thanks.
Best,
Tuo
      
     
0
Mihail
Telerik team
answered on 30 Jan 2013, 11:37 AM
Hello Tuo,

This is expected behavior. You already have a reference to your list style named "myListStyle"  and you can use it if you want to modify the style. If you want to apply the style pragmatically, you should read the section "Applying List Style Programmatically" from the help article you posted in order to understand how you can apply your custom list style to a paragraph.

The logic is rather complex as it has compatibility with older types of list styles provided mainly from MS Word.

I hope this is helpful!

Greetings,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Tuo
Top achievements
Rank 1
Share this question
or