跳转至

附录 A 对象模型速查


A.1 Excel 静态类

成员 说明
Open(path[, options]) 按扩展名自动识别格式打开
Open(path, format[, options]) 指定格式打开
Open(stream, format[, options]) 从流打开(必须指定格式)
Create() / Create(sheetName) / Create(string[]) / Create(format) 新建空簿
Create<T>(data[, sheetName, format, configure]) 新建并写 List\<T>
Create(DataTable[, sheetName, format]) 新建并写 DataTable
Write(path, Workbook[, options]) 写出工作簿
Write(path, SheetData[, options]) 写出单表(低层)
Write(path, DataTable[, sheetName, options]) 写出 DataTable
Write<T>(path, data[, sheetName, configure]) 写出 List\<T>
Read<T>(path[, sheetName, configure]) 读为 List\<T>
ReadAsDataTable(path[, sheetName, firstRowIsHeader]) 读为 DataTable
GetSheetNames(path) / GetSheetNames(stream) 列出工作表名
StreamRows(path, sheetName, onRow) 流式逐行读取
CreateWriter(path) / CreateWriter(stream) 创建流式写入器
Append(path, SheetData[, properties]) 追加数据
DetectFormat(path) 按扩展名返回格式
ReadWithProgress(path, sheetIndex, onProgress) 带进度读取

A.2 Workbook

成员 说明
Worksheets WorksheetCollection,按名称 / 索引访问
Names 命名区域(definedNames)列表
Properties WorkbookProperties 文档属性
Security WorkbookSecurity 文件级安全状态
Protection WorkbookProtection 工作簿保护
Format 当前工作簿格式
Date1904 1904 日期系统标志
Save() / SaveAs(path[, format]) 保存 / 另存
Save(stream, format) 存到流

A.3 Worksheet

成员 说明
Name 工作表名
Cells / Cell(address) / Cell(row, col) 单元格访问
Range(address) 区域访问
SetValue(...) 写入值
RowHeight / ColumnWidth / ColumnWidths 行高 / 列宽
AutoColumnWidths() 列宽自适应
Merge(...) / Unmerge(...) 合并 / 取消合并
MergedRanges 合并区域列表
Filter 自动筛选
Comments 批注
Validations 数据验证
ConditionalFormats 条件格式
Tables 超级表
Images 图片(读回)
AddImage(...) 添加图片
FreezeRows / FreezeColumns / FreezeHeader 冻结窗格
Protection 工作表保护
Style / HeaderStyle / DefaultStyle / RowStyles / ColumnStyles 样式
ImportData(...) 导入数据

A.4 模型类

类型 说明
Cell 单元格(Text / Number / Date / Boolean)
CellRange 区域(0-based 含端点)
CellStyle 单元格样式
BorderStyle / BorderEdge 边框
Hyperlink 超链接
NamedRange 命名区域
AutoFilter / FilterColumn 自动筛选
DataValidation 数据验证
ConditionalFormat / ColorScaleInfo / DataBarInfo / IconSetInfo 条件格式
XlTable / XlTableColumn 超级表
WorksheetImage / ImageAnchor 图片
SheetProtection / WorkbookProtection 保护
WorkbookProperties 文档属性
SheetData 低层工作表数据
DegradationInfo / DegradationCapability 降级回调
ExcelFormat / ExcelReadOptions / ExcelWriteOptions / WriteOptions<T> / ReadOptions<T> 枚举 / 选项
LiteColumnAttribute List\<T> 映射特性
CellRef A1 引用工具(静态类)
XlsxStreamWriter 流式写入器
LiteExcelException / LiteXlsxException / InvalidSheetNameException 异常