Formatting not retaining in Excel

Hi,

I am trying to export the data in excel using below code;

Workbook workbook
workbook.Save(response, HttpUtility.UrlPathEncode(fileName), ContentDisposition.Attachment, new XlsSaveOptions());

But if inside any data is containg html formating it does not retain the formating and it export the data with HTML tags.

could you please help me on this so that it export the proper formatted data.

Thanks
Sandeep

Hi,


Well, for your information, HTML data in the cells won’t be parsed unless you have used Cell.HtmlString attribute to specify the HTML tags/data to input into the cells in the code.

Let us know if you have any other query or confusion.

Thank you.

Hi,

I am not able to find attribute Cell.HtmlString, could you please send me sample code for this.

Regards,
Sandeep Kumar

Hi,


Please use our newer versions of the product (e.g v7.4.2.x) if you are using some older version of the product. See the sample code with the attached latest version/fix, the Cell.HtmlString is there in the API.

Sample code:

Aspose.Cells.Workbook xlWorkbook = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet xlWorkSheet = xlWorkbook.Worksheets[0];
Cells cells = xlWorkSheet.Cells;
//cells[“A1”].HtmlString = “Welcome<br>buddy!</html>”;
cells[“A1”].HtmlString = “Hello <u><i>there</i>, <br>this is a second sample text”;
Style style = cells[“A1”].GetStyle();
style.IsTextWrapped = true;
cells[“A1”].SetStyle(style);

xlWorkSheet.Cells.SetColumnWidth(0, 25);
xlWorkSheet.AutoFitRow(0);


xlWorkbook.Save(“e:\test2\Mysamplestring1.xlsx”);

Thank you.

Hi Amjad,

Thanks for you support. My another question is that will Aspose support in Silverlight using “Out of browser Mode” or Offline mode, I believe aspose does not support in offline mode.

Can you help on this.

Thanks & Regards,
Sandeep Kumar

Hi,


Please see the threads for using Aspose.Cells on Silverlight for your reference :
https://forum.aspose.com/t/30442
<a href="

Thank you.