禁用CSS在保存为HTML时
Contents
[
Hide
]
可能的使用场景
当将Excel文件保存为单页HTML时,通常CSS元素会嵌入到HTML文件中,并位于HEAD部分。如果将此文件作为电子邮件的内容/正文附件,大多数电子邮件客户端会剥离CSS元素,导致渲染不正常。Aspose.Cells 24.12版本引入了一个选项,可以选择性地禁用CSS,允许将样式直接应用于HTML元素本身。如果希望将HTML设置为电子邮件的内容/正文,请使用 HtmlSaveOptions.DisableCss 属性并将其设置为true。
** 禁用CSS在保存为HTML时**
以下示例代码展示了 HtmlSaveOptions.DisableCss 属性的用法。
示例代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load sample workbook | |
Workbook wb = new Workbook(sourceDir + "sampleDisableCss.xlsx"); | |
//Disable CSS | |
HtmlSaveOptions opts = new HtmlSaveOptions(); | |
opts.DisableCss = true; | |
//Save the workbook in html | |
wb.Save(outputDir + "outputDisable.html", opts); |