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

Free Support Forum - aspose.com

HTML format issue with background-color

Hi Team ,

We are using aspose-cells-21.7 for Excel report but it seems that there is an issue with below API

cell.setHtmlString(content);

when I have been trying to format blow content by invoking “setHTML(String)” API on cell , the issue occurred with background-color . “I am highlighted yellow” text is not being highlighted with yellow in the excel report . Please take a look and seeking your guidance or fix on this ?

This is a test:

I am italic

I am bold

I am underlined

I am strikethrough

I am large text

  • I am a bullet
  • <li class=“ql-indent-1”>I am an indented bullet

<span style=“color: rgb(230, 0, 0);”>I am red

I am heading 1


  1. I am a numbered bullet

<span style=“background-color: rgb(255, 255, 0);”>I am highlighted yellow

Thanks
Manish Kumar Gupta

@manishmca23,

I tried to paste your html string/code in a file and save it as html. When I open the file into the browser, it does not show highlighted background either. Please find attached the html file for your reference.
files1.zip (406 Bytes)

If you still think it is an issue with Aspose.Cells, kindly use html string to make an html file, zip the file and attach it here, we will check it soon.

@manishmca23
If you use cell.setHtmlString, so all value are converted into a cell.
MS Excel only supports background color for the whole cell.Setting background color for part content of the cell is not supported in MS Excel.

Thank you , Simon for your response .

I also have another question . The same API setHTML(String) is not working for Hyperlink . I am using the same JAR - "aspose-cells-21.7"

“market information” should be displayed as hyperlink in Excel however it is not working . Please help

Please help

below is being passed as input .

Here is where will will provide an overview of the business, ownership and other <a href=“www.uwaterloo.ca” rel=“noopener noreferrer” target=”_blank">market information.



"

@manishmca23,

I did test your scenario/case using our latest version/fix: Aspose.Cells for Java v22.6 (Download | Maven) , it works fine and as expected. See the following sample code that I used with latest version/fix. The output file has the hyperlink in tact.
e.g.
Sample code:

        Workbook workbook = new Workbook();
        Worksheet worksheet = workbook.getWorksheets().get(0);
        Cell cell = worksheet.getCells().get("A1");
        cell.setHtmlString("<html><a href=\"www.uwaterloo.ca\" rel=\"noopener noreferrer\" target=\"_blank\">market information</a></html>");
        workbook.save("f:\\files\\out1.xlsx");

Please try our latest version/fix and if you still find any issue, kindly share your source HTML string/code in a separate file (please zip it first prior attaching), we will check it soon.

@manishmca23

If you use cell.setHtmlString , so all value are converted into a cell.
MS Excel only supports hyperlink for the whole cell.
Setting hyperlink for part content of the cell is not supported in MS Excel.

Thank you Amjad and Peyton .

@Amjad - Will Aspose.Cells for Java v22.6 work for part content of the cell for Hyperlink ?

@Peyton - what is the alternative solution for this ?
Do you have any other API which will hyperlink only part content of the cell ?

Aspose.Cells follows MS Excel standards and specifications regarding hyperlinks. So, No, similar to MS Excel, Aspose.Cells cannot add hyperlink for selected text/string in the cell (MS Excel does not allow this either).

Please try your scenario/case in MS Excel manually, i.e., try to add hyperlink for selected text in the cell and you will notice you cannot add link for selected text in the cell.

To cope with this limitation put forth by MS Excel, you might try using shapes/controls, e.g. TextBox, and write your text/data accordingly.

Thanks Amjad for the clarification .

Currently we are using “aspose-cells-18.2” to generate couple of excel reports.

If we upgrade it with “aspose-cells-21.7” , do you think that this upgrade will impact our existing excel reports ?

These exiting excel reports are working fine with “aspose-cells-18.2” . however we want to use “aspose-cells-21.7” which has some couple of fixes which are not available in aspose-cells-18.2.

Please advise . Can we upgrade our system with aspose-cells-21.7 ?

@manishmca23,

If you upgrade to newer aspose-cells-21.7 version, I think it should not impact much regarding your existing reports, it should work the same way as before. But I recommend you to kindly upgrade to latest version/fix: Aspose.Cells for Java v22.6 which has more enhancements and fixes. Moreover, if you upgrade your subscription to newer version, then you can avail official releases or hotfixes that would be published in the next whole year. Furthermore, in case you find any issue, your issue would be fixed in monthly releases or hotfixes which you can get for free.

Thank you, Amjad for your suggestion .

I am not getting desired output for the below HTML text

Recommendation

Recommend approval of the following:

  1. request


  • Approve a Please see Transaction overview for further detail.

- Please note Commitments are due by Monday, August 2.

- Maintain Risk

- Reduce – Risk.

  1. Syndication Strategy
  2. Exceptions
  3. Note
  4. Booking
  5. Approval


I am testing with aspose-cells-21.7 and my output as below . I have emphasized the issue in the below output . These should start in the next line not in same row

Please advise

Recommendation

Recommend approval of the following: 1. request

Approve a Please see Transaction overview for further detail.

  • Please note Commitments are due by Monday, August 2.

  • Maintain Risk

  • Reduce – Risk. 1. Syndication Strategy

  1. Exceptions
  2. Note
  3. Booking
  4. Approval

@manishmca23

It works OK both in aspose-cells-21.7 and aspose-cells-22.6 with your html text.
output.zip (6.2 KB)

If you still find the issue on your side, please share us runnable code/project to reproduce it.

Thanks Peyton for your reply . I cant share the project due to security reason . However it is not formatting in the same way as you attached.
I am using “setHTML(String)” on Cell . Can you pls try one more time with below HTML string using aspose-cells-21.7

Recommendation

Recommend approval of the following:

  1. request


  • Approve a Please see Transaction overview for further detail.

- Please note Commitments are due by Monday, August 2.

- Maintain Risk

- Reduce – Risk.

  1. Syndication Strategy
  2. Exceptions
  3. Note
  4. Booking
  5. Approval


When I am posting reply , I cant see the HTML string which being used for testing .
so I am attaching here html.docx (12.7 KB)

@manishmca23

We can reproduce the issue as you mentioned with your newly attached html string(There are some line break differences comparing with your previous shared one.).
We have logged a ticket with the ID “CELLSJAVA-44741” for it.

@manishmca23,

This is to inform you that your issue has been resolved now. The fix will be included in the next official release (Aspose.Cells v22.8) which is scheduled to be released in the second week of August 2022. You will also be notified when the next version is published.

Thanks for the fix . We have a license till July 31, 2021 .
Can we use this fix in the same license version ?

@manishmca23,

No, I am afraid, to use the newer versions of the API, you need to upgrade your subscription. There is no other alternative to fix your issue. You may wait until we will publish the next version in the next month, so you may upgrade your subscription accordingly.

Thanks, Amjad , I have been checking with my manager to renew the subscription and will let you know soon about this .

I have a query

Will latest API “Aspose.Cells v22.8” be compatible with Java 5, 6 , 7 and 8 ?

@manishmca23,

Aspose.Cells for Java supports JDK1.6 (Java 6) and greater versions, see the System Requirements page for your reference.