Converting XLSX file to Html and displaying in sfRichTextEditor

Hi,

We need ability to display Excel files in our Xamarin Forms app. On iOS we use QLPreviewController which works very well and shows file as it looks in original, but with Android we can't achieve the same.

When file is displayed there is a big gap at the top and contents are shown at the bottom as per image below:


This is how we convert and display excel files on Android:

            var stream = new MemoryStream( viewModel.Data );

            ExcelEngine excelEngine = new ExcelEngine();

            IWorkbook workbook = excelEngine.Excel.Workbooks.Open( stream );

            MemoryStream htmlStream = new MemoryStream();

            workbook.SaveAsHtml( htmlStream, Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default );

            htmlStream.Position = 0;

            string htmlText = IgnoreVoidElementsInHTML( System.Text.Encoding.UTF8.GetString( htmlStream.ToArray() ) );

            htmlStream.Dispose();

            stream.Dispose();

            SfRichTextEditor rtfViewer = new SfRichTextEditor() { HtmlText = htmlText, ShowToolbar = false, ReadOnly = true, HorizontalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand, VerticalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand };

            Content = rtfViewer;

I've attached sample excel file, you can see that after conversion it looses colours and content placement is at the bottom instead of top.

Is there a better way to display excel files on Android using your components?



Attachment: Sample_e04295c3.zip

2 Replies

ER Ernest November 10, 2021 12:44 AM UTC

Solved it. Instead of using RichTextEditor I've switched to WebView and it shows pr



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team November 10, 2021 10:55 AM UTC

Hi Ernest, 

Greetings from Syncfusion. 

We are glad that the issue is resolved at your end. Kindly let us know if you need any further assistance. 

Regards, 
Keerthi. 


Loader.
Up arrow icon