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

Free Support Forum - aspose.com

CSS Prefix not applied to all styles

When saving a worksheet to HTML, not all generated styles have the specified prefix when


Specifically, there is a “td” style generated that does not have the desired prefix.

The purpose for this td is presumably for showing gridlines - but these don’t seem to be working either.

The problem has been reproduced on 17.1.0 and 17.1.8

Attached is a console test case the re-creates the error
Attached also is the output of the test case. Note the rogue style output:

.test_font2
{
color:#0000FF;
font-size:18pt;
font-weight:700;
font-style:italic;
font-family:“Arial”,“sans-serif”; }
td
{mso-style-parent:test_style0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
white-space:nowrap;

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Thanks,<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>
<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Mark<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>

Hi,


Thanks for the output file and sample JAVA program.

Could you also provide us template file “Book1.xlsx”, we will check it soon.

Thank you.

Sorry - I forgot to add it. The .xls file isn’t anything special. Attached anyway.


Mark

Hi,


Thanks for providing us template file.

I did evaluate your issue using your template file and sample code (you shared JAVA program earlier) and found the behavior/issue as you mentioned. Aspose.Cells only adds prefix “test_” to CSS .class selector and it does not add prefix to other types of CSS selectors (e.g element selectors, i.e., td, tr, col, br, etc.). Do you need to add CSS prefix to all the selectors in the HTML file? Please elaborate the details a bit more with your expected file (if possible), we can log a ticket for it for feasibility analysis into our database.

Thank you.
Hi,

Thanks for getting back to me.

The problem is that in my implementation, I am not saving the HTML render of the spreadsheet to a file, but to a String and including that String inside a bigger page that includes other content - including tables.

This should not be an alien use of the API. I have to assume the .setCellCSSPrefix() method was specifically introduced to provide a namespace for a given render that avoids generated styles colliding with other content.

The problem is that the "td" style you are creating is global and will apply to every on the page - breaking the whole purpose of the css-prefix namespace along the way.

One potential solution to this may be to generate a class for the table and apply a selector the the "td"s to only affect those TDs inside the table.

To illustrate: This will make all TDs on the page red:

td { color:red }

aaa
bbb


But applying a custom class to the generated table (with css prefix) makes only the intended TD red:

.myprefix_style1 td { color:red }

aaa

bbb


Furthermore, can I bring this thread to your attention:

<a rel="nofollow" href="</a></div><div><br></div><div>This seems to be the same issue (for Cells.NET) which (apparently) now applies the css-prefix all generated styles including the TD.</div><div><br></div><div>Hope all that helps.</div><div><br></div><div>Mark</div><div><br></div>

Hi Mark,


Thanks for sharing further details.

Could you provide us your expected output String in a text file similar to what you provided us “output.txt” (by Aspose.Cells APIs) earlier in your first post in this thread. You may edit the output.txt file manually by yourself and make the final file as per your requirements regarding CSS prefix selectors, this will help us really to evaluate your issue/requirements precisely to figure it out (if possible) soon.

Thank you.