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

Free Support Forum - aspose.com

Opening HTML files -- how to reference CSS

Hi,

I use Aspose Cells to open and convert HTML reports into proper .xlsx Excel files. Aspose handles the “conversion” of our HTML into xlsx okay, but it ignores the referenced CSS stylesheet. Is there a way to direct Aspose to use a stylesheet so the resulting Excel file has formatted text/colors?

I don’t think we are doing anything exotic in our CSS styling, and if I manually open our HTML files in Excel everything is styled accordingly. I’d like to get the equivalent behavior when opening the HTML files with Aspose.

I’d be happy to post a sample HTML + CSS if you could direct me how to. Thanks!

Here are some sample files

rx.zip (2.0 KB)

I think I more or less figured this out, although perhaps Aspose could be improved to support some very common CSS practices. It’d be nice if Aspose at least matched what Excel itself can handle when opening HTML/CSS.

  1. the CSS “font” tag is ignored by Aspose Cells. You can’t do “font: bold 8pt tahoma,arial,sans-serif;” but you can do “font-weight: bold; font-family: tahoma,arial,sans-serif; font-size: 8pt;”

  2. Aspose doesn’t appear to pull in a referenced CSS that is on a web server. It does okay with a CSS file on the local file system, or inline CSS.

  3. Aspose throws an exception when it encounters a url() reference. I had to take out the following from my CSS: “background: #0066cc url(/CommonEnterprise/WebBuilder/default/bg-horizontalnav.gif) repeat-x top;”

@mikebruner,

Thanks for your query.

It seems that you have figured it out right that Aspose parse the tags is specific format and cannot parse combined tags like “font: bold 8pt tahoma,arial,sans-serif;”.

Regarding the referenced CSS files from web, Aspose.Cells does not fetch those information and relies on the CSS data on the local disc.

I could not observe any exception while converting your sample Html file to Excel file. Please send us a console application along with the template Html file, which can be used to reproduce this exception here.

@mikebruner,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46365 - Referenced CSS stylesheets ignored while opening Html

@mikebruner,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46365”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSNET-46365) have been fixed in Aspose.Cells for .NET v18.11. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi