HTML to Excel ignores CSS

Hello,

we are evaluateing aspose.cells right now and we have a HTML file with CSS. We import the HTML into a new workbook and save it. But the xlsx is missing the CSS-Styles. If we just copy & paste the table into a empty sheet it works.

What are we doing wrong here? The html-file is attached.article.zip (766 Bytes)

Code:

import com.aspose.cells.HTMLLoadOptions;
import com.aspose.cells.LoadFormat;
import com.aspose.cells.SaveFormat;
import com.aspose.cells.Workbook;

/**

  • Created on 25.08.2017.
    */

public class AsposeTest {
public static void main(String[] args) throws Exception {

    HTMLLoadOptions options = new HTMLLoadOptions(LoadFormat.HTML);

    Workbook htmlBook = new Workbook("C:\\temp\\article.html", options);
    htmlBook.save("C:\\temp\\article.xlsx", SaveFormat.XLSX);
}

}

Thanks for your help

@mpsCai,

Thanks for the template file and sample code.

Well, MS Excel also ignores CSS styles/formattings when you open your HTML file into MS manually. Aspose.Cells follows MS Excel standards and specifications when parsing or rendering HTMLs, so it is not an issue with the product.

Thank you.

Okay thanks for the information,

but is there any way to get a formatted HTML into Excel via Aspose?

Thanks again

@mpsCai,

Well, Aspose.Cells supports MS Excel oriented HTML files. You may open the HTML file into MS Excel manually and apply formattings using “Format Cells…” dialog box and then re-save to HTML (Web page) file. Now Aspose.Cells should be able to parse the file fine.

Thank you.