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