We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Interpret rich text string in excel from database field

We have requirement where we are storing a rich text formatted data from UI into a database field. We need to retrieve data from that column and put it into excel cell. We want that show that rich text data into excel using aspose cell, how to do this?



Thanks for using Aspose APIs.

You can do it using HTML. Please see this article for more detail. It should fit your needs. Let us know your feedback.

I have a rich text file in this format :-
{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\f2\fbidi \fmodern\fcharset0\fprq1{*\panose 02070309020205020404}Courier New;}
{\f3\fbidi \froman\fcharset2\fprq2{*\panose 05050102010706020507}Symbol;}{\f10\fbidi \fnil\fcharset2\fprq2{*\panose 05000000000000000000}Wingdings;}{\f10\fbidi \fnil\fcharset2\fprq2{*\panose 05000000000000000000}Wingdings;}
{\f37\fbidi \fswiss\fcharset0\fprq2{*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}
{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{*\panose 02040503050406030204}Cambria;}
{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}
{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{*\panose 020f0502020204030204}Calibri;}
{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}…

This is not a HTML format. To generate this code we can save word doc as a .rtf and when we open it in notepad we can see this code.


Thanks for sharing further details.

Well, Aspose.Cells is a spreadsheet management library so it cannot parse .rtl file (contents). I think to accomplish your task, one approach can be be, i.e., you may try to use Aspose.Words API to first save your RTL file/contents in PDF file format and then use Aspose.Pdf API to convert the PDF file to Excel spreadsheet. See the documents for your reference:

Hope, this helps a bit.

var filePath = @“C:\TEMP\test.rtf”;
AsposeWords.FileFormatInfo info = AsposeWords.FileFormatUtil.DetectFileFormat(filePath);
AsposeWords.LoadOptions loadOptions = new AsposeWords.LoadOptions();
loadOptions.LoadFormat = AsposeWords.LoadFormat.Rtf;
AsposeWords.Document doc = new AsposeWords.Document(filePath, loadOptions);
MemoryStream ms = new MemoryStream();

         doc.Save(ms, AsposeWords.SaveFormat.Pdf);
        AsposePdf.Document pdfDocument = new AsposePdf.Document(ms);
        AsposePdf.ExcelSaveOptions excelsave = new AsposePdf.ExcelSaveOptions();
        pdfDocument.Save(@"C:\TEMP\PDFToXLS_out.xls", excelsave);

Thank you for replying and helping me out.
I tried this code but In excel output seems to be different. I was expecting a two bullet point but it didn’t showed up there.

I have also tried to convert into HTML first and then used Cell.HtmlString but there also I didn’t get the bullets.
Can you help me on this please. Or any other way I can do it?


This forum is specific to Aspose.Cells related queries. Since your issue/task involves multiple APIs, so I am moving your thread to Aspose.Total forums where we could help you better.

We also need your sample RTL file, PDF file and Excel file (XLS) to evaluate your issue precisely.

We need your HTML string to test it using Cell.HtmlString attribute. Moreover, please note, Aspose.Cells follows MS Excel standards when reading/parsing or writing HTMLs. If MS Excel supports to read/parse your HTML fine, Aspose.Cells will do the same.

I am not able to upload .RTF file. I am pasting my code here. Ord you can generate .RTF file by saving a word doc as .rtf.

testrtftoPdf.pdf (38.6 KB)

TEMP.zip (44.2 KB)
This has all the files


The output PDF looks fine, and there are unknown characters in the output Excel file when we convert PDF to Excel format. Microsoft Excel does not provide a button to create bullets in the text. However, we can add bullet symbols to a worksheet in Excel. We have logged an investigation under the ticket ID PDFNET-44357 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.