Unsupported HTML elements causing issue in excel export

Or can you provide a flag that when set to true, it will always suppress the error and consider default value for given tag. For ex. SuppressErrorWithDefaultTagValue = True

@Bhumika.Shah
At present, there may be some exceptions in the handling of initial values. As an alternative, you can set specific values to solve the issue.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-55974

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Yes, actually suddenly lot many clients have started facing issue. New values are encountered each time. We replace it in database every time through workaround script. Though it’s not convenient to run each time when issue surfaces and when it has new values client needs to connect again for support.

Clients are copying such HTML formatted data from external sources and its so frequent that we cannot control it. Though our HTML editors does not through issue, so it gets entered into the system but while being processed by Aspose, it throughs exception.

@Bhumika.Shah
Thank you for your feedback. Would you like to provide sample files and test code? We will check them soon.

You had earlier tested it with our tags having issue. Can you please use it with the same code. Thanks.

Currently only “background-color: initial” causing issue among above sample data with other initial values.

@Bhumika.Shah
Thank you for your feedback. Once there are updates, we will notify you promptly.

1 Like

I have 1 more question. We are using multiple old & new versions of Aspose in our different versions. In old Aspose version 20.4.0.0 we have noticed that export to csv results into simplified plain text only when HTML formatted text is inserted, whereas in newer version 23.6.0.0. it results into HTML formatted values. Can you please see for how it occurs or is there any option that we can have same functionality in newer versions. We want to remove HTML formatting tags in csv export as they make the content unreadable. Thanks.

@Bhumika.Shah
Would you like to provide sample files, expected result files, and runnable test code? If you can take a screenshot and highlight the issue, it will be very helpful for us to locate the issue. We will check it soon.

Can you please use the same sample code from May 30 comment that you have provided. Only need to export to csv instead of xlsx.

Input:
<span style=““color: rgb(231, 76, 60);””>Test
Expected Result:
Test
Actual Result:
<span style=““color: rgb(231, 76, 60);””>Test

@Bhumika.Shah
By testing on the latest version v24.8 using the following sample code, we can obtain the correct results. Please refer to the attachment. out_net.zip (255 Bytes)

DataTable table = new DataTable();
table.Columns.Add("Test Field");
string[] dataRow = { "<span style=““color: rgb(231, 76, 60);””>Test" };
table.Rows.Add(dataRow);

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells.ImportData(table, 0, 0, new ImportTableOptions
{
    IsFieldNameShown = true,
    IsHtmlString = true
});

//Set wrapping text style to the cell.
Style style = workbook.CreateStyle();
style.IsTextWrapped = true;
cells["A2"].SetStyle(style);

workbook.Save(filePath + "out_net.csv");

If you still have questions, please provide your test code and we will check it soon.

Can you please suggest that if 3 lines for setting lines are necessary in this code. Though I have tested them also not working. Do you see this for 23.6.0.0 also?

@Bhumika.Shah
We can obtain correct results by testing on both the latest version v24.8 and the old version v23.6 using the following sample code. Please refer to the attachment. csv_result.zip (538 Bytes)

DataTable table = new DataTable();
table.Columns.Add("Test Field");
table.Columns.Add("Test Field2");
table.Columns.Add("Test Field3");
string[] dataRow = { "<span style=““color: rgb(231, 76, 60);””>Test" };
table.Rows.Add(dataRow);

string[] dataRow2 = { "<span style=““color: rgb(231, 76, 60);””>Test<span style=““color: rgb(231, 76, 60);””>Test<span style=““color: rgb(231, 76, 60);””>Test" };
table.Rows.Add(dataRow2);

string[] dataRow3 = { "<span style=““color: rgb(231, 76, 60);””>Test", "<span style=““color: rgb(231, 76, 60);””>Test", "<span style=““color: rgb(231, 76, 60);””>Test" };
table.Rows.Add(dataRow3);

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells.ImportData(table, 0, 0, new ImportTableOptions
{
    IsFieldNameShown = true,
    IsHtmlString = true
});

//Set wrapping text style to the cell.
Style style = workbook.CreateStyle();
style.IsTextWrapped = true;
cells["A2"].SetStyle(style);

workbook.Save(filePath + "out_net24.8.csv");

If you still have questions, please provide your runnable test code and data files, and we will check them soon.

I need some time to check on the above one.

Meanwhile I could find 1 more tag with multiple usage causing issue.

color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;

inherit keyword caused issue in Aspose. I could see that previously initial tag, used in same way, had caused issue. I could also find that Inherit, Initial, Unset, and Revert are keywords used in CSS inheritance. Can you please try to resolve the same for later versions.

@Bhumika.Shah,

Could you please share a use case (sample (runnable) code and sample files (input (if any) and output file) to demonstrate the issue. Also, provide your desired output file for reference. We will evaluate and log appropriate ticket for your issue/requirements.

@Bhumika.Shah
We can run the following code normally without any abnormal information on the latest version v24.9. Please refer to the attachment. out_net24.9.zip (280 Bytes)

DataTable table = new DataTable();
table.Columns.Add("Test Field");
table.Columns.Add("Test Field2");
table.Columns.Add("Test Field3");
string[] dataRow = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow);

string[] dataRow2 = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow2);

string[] dataRow3 = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test", "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test", "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow3);

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells.ImportData(table, 0, 0, new ImportTableOptions
{
    IsFieldNameShown = true,
    IsHtmlString = true
});

//Set wrapping text style to the cell.
Style style = workbook.CreateStyle();
style.IsTextWrapped = true;
cells["A2"].SetStyle(style);

workbook.Save(filePath + "out_net24.9.csv");

If you still have questions, please provide your runnable test code and data files, and we will check them soon.

Above issues for html tags occur in excel export and not csv.

Also can you please suggest which are the tags that you consider for formatting. For ex. I get errors for background-color, color and font-size. Are there more such which you process for values.

@Bhumika.Shah
On the latest version v24.9, we can run the following code normally and save the file to xlsx format without any exception messages. Please refer to the attachment.out_net24.9.zip (6.8 KB)

DataTable table = new DataTable();
table.Columns.Add("Test Field");
table.Columns.Add("Test Field2");
table.Columns.Add("Test Field3");
string[] dataRow = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow);

string[] dataRow2 = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow2);

string[] dataRow3 = { "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test", "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test", "<span style=““color:inherit; font-feature-settings:inherit; font-kerning:inherit; font-optical-sizing:inherit; font-size-adjust:inherit; font-stretch:inherit; font-style:inherit; font-variant:inherit; font-variation-settings:inherit; font-weight:inherit; line-height:inherit;””>Test" };
table.Rows.Add(dataRow3);

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells.ImportData(table, 0, 0, new ImportTableOptions
{
    IsFieldNameShown = true,
    IsHtmlString = true
});

//Set wrapping text style to the cell.
Style style = workbook.CreateStyle();
style.IsTextWrapped = true;
cells["A2"].SetStyle(style);

workbook.Save(filePath + "out_net24.9.xlsx");

Would you like to provide your runnable test code and data files? we will check it soon.