Excel Read HelperRead Large Excel To Data Table Async 方法
异步读取大型 Excel/CSV 并转换为 DataTable(支持类型推断)
Definition
命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static Task<DataTable> ReadLargeExcelToDataTableAsync(
string filePath,
int headerRows = 1,
int batchSize = 1000,
bool autoDetectType = false,
IProgress<int>? progress = null,
Encoding? csvEncodingOverride = null,
CancellationToken cancellationToken = default
)参数
- filePath String
- 文件路径,支持 .xlsx、.xls、.csv 格式
- headerRows Int32 (Optional)
- 表头行数(1 或 2)
- batchSize Int32 (Optional)
- 每批处理的行数
- autoDetectType Boolean (Optional)
- 是否自动检测列数据类型
- progress IProgressInt32 (Optional)
- 进度报告回调
- csvEncodingOverride Encoding (Optional)
- 仅对 .csv 生效的编码覆盖项;为 null 时自动检测
- cancellationToken CancellationToken (Optional)
- 取消令牌
返回值
TaskDataTable[缺少 "M:Suresking.Utility.ExcelReadHelper.ReadLargeExcelToDataTableAsync(System.String,System.Int32,System.Int32,System.Boolean,System.IProgress{System.Int32},System.Text.Encoding,System.Threading.CancellationToken)" 的 <returns> 文档]