[]
CsvSaveOptions, HtmlSaveOptions, PdfSaveOptions, SjsSaveOptions, XlsxSaveOptions此抽象类存储保存操作的目标 SaveFileFormat,并定义特定格式保存选项类型共享的通用约定。将具体子类传递给保存 API(例如 Workbook.save(String,SaveOptionsBase)或 IWorksheet.save(String,SaveOptionsBase)),可以控制如何为特定输出格式写入内容。
派生类通过 setFileFormat(SaveFileFormat) 初始化文件格式,并为其对应格式公开其他设置,例如 CSV、HTML、PDF、SJS 或基于 XLSX 的输出。使用 getFileFormat() 可检查与具体 saveoptions 实例关联的格式。
final SaveFileFormatprotected final voidsetFileFormat(SaveFileFormat value) 此值标识当前保存选项实例使用的 SaveFileFormat。具体子类将此值设置为它们支持的格式,例如 CsvSaveOptions的 SaveFileFormat.Csv 或 PdfSaveOptions 的 SaveFileFormat.Pdf。
PdfSaveOptions options = new PdfSaveOptions();
SaveFileFormat fileFormat = options.getFileFormat();
此 protected 方法由 SaveOptionsBase 子类用于定义选项实例表示哪个 SaveFileFormat。分配的值由 getFileFormat() 返回。
class CustomSaveOptions extends SaveOptionsBase {
void usePdfFormat() {
setFileFormat(SaveFileFormat.Pdf);
}
}
CustomSaveOptions options = new CustomSaveOptions();
options.usePdfFormat();
value - 要与这些保存选项关联的文件格式;可以为 null。