防止在保存到 HTML 时导出隐藏的工作表内容
您可以将 Excel 工作簿保存到 HTML。但是,如果工作簿包含隐藏工作表,则 Aspose.Cells 默认将隐藏工作表内容导出到 HTML 输出(_ files) 目录,其中包含工作表、图像、tabstrip.htm、stylesheet.css 等文件。有时,以这种方式导出隐藏工作表的内容并不合适。例如,如果隐藏工作表包含不应导出到_文件目录。
Aspose.Cells 提供了HtmlSaveOptions.ExportHiddenWorksheet 财产。默认情况下,它设置为真的 和隐藏的工作表被导出到 HTML。如果你设置它错误的 Aspose.Cells 不会导出隐藏的工作表内容。
This file contains 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
// The path to the documents directory.
string dataDir = RunExamples . GetDataDir ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
// Create workbook object
Workbook workbook = new Workbook ( dataDir + "WorkbookWithHiddenContent.xlsx" ) ;
// Do not export hidden worksheet contents
HtmlSaveOptions options = new HtmlSaveOptions ( ) ;
options . ExportHiddenWorksheet = false ;
// Save the workbook
workbook . Save ( dataDir + "HtmlWithoutHiddenContent_out.html" , options ) ;