Completed
Last Updated: 31 Oct 2018 07:53 by ADMIN
ADMIN
Boby
Created on: 15 Sep 2016 16:25
Category: Spreadsheet
Type: Bug Report
3
Spreadsheet: NotSupportedException is thrown when trying to show .emf image
The BitmapImage class throws the exception. We could show some kind of no-image-placeholder instead of throwing exception, or skip the image.

Telerik Reporting creates such files.

Attached is a sample project demonstrating how to customize the Open command descriptor to remove .emf images just after importing the document.

Available in R3 2018 Official Release Version.
Attached Files:
6 comments
ADMIN
Tanya
Posted on: 23 Apr 2018 10:31
Hi all,

Sergey, thank you very much for sharing the approach you are using. However, it would be applicable only if the document is imported in the code but to handle the case in which the shortcut or the UI button is used by the user to open a document, you will need to override the command descriptor. I prepared an example which you can find attached to the item.

Regards,
Tanya
Sergey
Posted on: 15 Apr 2018 15:38
This is a suggested work-around for an end-user.
For the development team please see https://feedback.telerik.com/Project/184/Feedback/Details/195793-spreadprocessing-add-possibility-to-register-custom-image-decoders
Ivan Pelly
Posted on: 15 Apr 2018 15:00
Is this a suggested work-around for an end-user, or for the development team?
Sergey
Posted on: 15 Apr 2018 12:13
Found a better solution without try-catch. After loading document:

                List<FloatingShapeBase> emfImages = new List<FloatingShapeBase>();

                foreach (var shape in worksheet.Shapes)
                {
                    if (shape is FloatingImage floatingImage &&
                        (floatingImage.ImageSource?.Extension?.ToLower() ?? "") == "emf")
                    {
                        emfImages.Add(floatingImage);
                    }
                }

                worksheet.Shapes.Remove(emfImages);
ADMIN
Tanya
Posted on: 28 Mar 2018 15:54
Thank you for sharing the approach, Sergey.
Sergey
Posted on: 09 Jan 2018 13:06
This exception hard to handle, because it is in Measure. See attached files.

Application.DispatcherUnhandledException Event doesn`t resolve issue in my application. There is recursion in Measure, application hangs.

My workaround:

        private class RadSpreadsheetEx : RadSpreadsheet
        {
            public RadSpreadsheetEx()
            {
                Style = (System.Windows.Style)System.Windows.Application.Current.FindResource(typeof(RadSpreadsheet));
            }

            protected override Size MeasureOverride(Size constraint)
            {
                try
                {
                    return base.MeasureOverride(constraint);
                }
                catch (NotSupportedException)
                {
                    Workbook workbook = new Workbook();
                    workbook.Protect("");
                    Workbook = workbook;

                    return constraint;
                }
            }
        }


Attached Files: