Unsupported HTML elements causing issue in excel export

I am using asheet.Cells.ImportData(Datatable). There is no other significant code used here. Please note that it was found during export of some users.

Also, I just wanted to confirm that setting .IsHTMLString to True or False does not make any difference in csv export.

@Bhumika.Shah,

I tested using the following sample code. I created a dynamic DataTable in code. I added a column having your mentioned HTML tags in it. When I try to import data using Cells.ImportData, I still get the same exception(“System.FormatException : Input string was not in a correct format”) as we did get using Cell.HtmlString attribute.
e.g.
Sample code:

System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
table.Columns.Add("TestField");
string[] addrow = {"1", "Name1", "<font color=\"rgba(0, 0, 0, 0)\"><span style=\"background-color: var(–color-field-bg); color: var(–color-field-text); font-size: 0px;\">Test</span>"};
table.Rows.Add(addrow);

var workbook = new Workbook();
var ws = workbook.Worksheets[0];
ws.Cells.ImportData(table, 0, 0, new ImportTableOptions
{
    IsFieldNameShown = true,
    ConvertNumericData = true,
    IsHtmlString = true


}); //exception
workbook.Save("g:\\test2\\out1.csv"); 

In short, either you are not giving us actual (input) HTML string or you are using some other code segment or HTML string for your case. Since you are not ready to give us sample code to reproduce the issue on our end, so how could we evaluate your issue or figure it out? Please give us exact sample code (if possible). By the way, we are using Aspose.Cells for .NET v24.3. Are you using same version of some older version, which version? Please try using latest version.

Yes, it won’t make any difference. The reason is since CSV is text file format, so all the formatting would be lost when rendering to CSV.

@Bhumika.Shah ,

We are pleased to inform you that your issues CELLSNET-55416, CELLSNET-55417 and CELLSNET-55436 have been resolved. The fix will be included in an upcoming release (Aspose.Cells v24.4) that we plan to release in the first half of April 2024. You will be notified when the next version is released.

Thank you. Actually, in my previous input < was replaced to < and > to >. So correct input was not provided.

Please replace < and > in below input accordingly and test.

System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add(“ID”);
table.Columns.Add(“Name”);
table.Columns.Add(“TestField”);
string[] addrow = {“1”, “Name1”, " <font color="rgba(0, 0, 0, 0)"><span style="background-color: var(–color-field-bg); color: var(–color-field-text); font-size: 0px;">Test111</span>
"};
table.Rows.Add(addrow);

var workbook = new Workbook();
var ws = workbook.Worksheets[0];
ws.Cells.ImportData(table, 0, 0, new ImportTableOptions
{
IsFieldNameShown = true,
IsHtmlString = true
}); //exception
workbook.Save(“g:\test2\out1.csv”);

Please note that below output was found for some users only during export to csv as I noticed.

Output
<span class=““ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak”” dir=““ltr””><font color=““rgba(0, 0, 0, 0)””><span style=““background-color: var(–color-field-bg); color: var(–color-field-text); font-size: 0px;””>Test

You can also refer to the image below where new span was added upon automatically.

image.png (25.0 KB)

@Bhumika.Shah
Can you share a file which contains your template codes? Then they will not be escaped .

Test.zip (637 Bytes)

Please refer to the above csv file. Please note that it was observed by some of users as for now.

@Bhumika.Shah,

I tested your scenario/case using the following sample code (“<” was replaced to “&lt;” and “>” to “&gt;”), it works fine.
e.g.
Sample code:

System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
table.Columns.Add("TestField");
string[] addrow = {"1", "Name1", " &lt;font color=\"rgba(0, 0, 0, 0)\"&gt;&lt;span style=\"background-color: var(–color-field-bg); color: var(–color-field-text); font-size: 0px;\"&gt;Test111&lt;/span&gt;<br>"};

table.Rows.Add(addrow);

var workbook = new Workbook();
var ws = workbook.Worksheets[0];
ws.Cells.ImportData(table, 0, 0, new ImportTableOptions
{
IsFieldNameShown = true,
IsHtmlString = true
}); 
workbook.Save("g:\\test2\\out1.csv");

Please find attached the output CSV file for your reference.
out1.zip (289 Bytes)
You will notice the CSV file by Aspose.Cells is rendered as expected.

I did not get your mentioned issue, something similar to:
i.e.,

Thats true. This was caused to some user and not all so far. It’s different than previously mentioned which were always reproducible.

@Bhumika.Shah,

You should check what sample code is being used/processed on the machines of those users. I guess there is something wrong/different either with code or data being used for those users.

Data was same. I am also curious and output in image that I had shown is reported by same user.

@Bhumika.Shah,

That is really strange. Since we could not reproduce the issue on our end, we cannot evaluate or figure out the issue. Anyways, we still think there is something different on the machines for those users.

Ok. Kindly please ensure once that no part of code can yield “class a b c d” kind of results.

@Bhumika.Shah,

Yes, we already ensured and such a result, i.e., “a b c d” is not yielded by Aspose.Cells APIs.

1 Like

Whenever the date is finalized for release, please update. So that the team can schedule it accordingly.

@Bhumika.Shah
We plan to release Aspose.Cells v24.4 this week. Once the version v24.4 is released, we will notify you promptly.

1 Like

@Bhumika.Shah,

Moreover, we have started the release process and if everything goes smoothly, we will publish the new version, i.e., Aspose.Cells for .NET v24.4, tomorrow.

1 Like

The issues you have found earlier (filed as CELLSNET-55416,CELLSNET-55417,CELLSNET-55415,CELLSNET-55436) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

May I know how the rgba shall be processed in below cases. Although my input had font-color=rgba(0,0,0,0) which seems to have no effect and simply removed, when I use it with color it seems to provide white forecolor with any input. Though I have not seen this as input in client’s database, I understand. Just wanted to make it clear about how they are processed.

Please add < and > at both ends.

span style="color: rgba(0, 0, 0, 0); ">Test1</span
span style="color: rgba(255, 0, 0, 0); ">Test2</span
span style="font-color: rgba(255, 0, 0, 0); ">Test3</span
span style="font-color: rgba(0, 0, 0, 0); ">Test4</span