C# · 12月 20, 2021

C# — 使用Aspose.Cells创建和读取Excel文件

使用Aspose.Cells创建和读取Excel文件

1. 创建Excel

Aspose.Cells.License li = li.SetLicense( Aspose.Cells.Workbook wk = Worksheet ws = wk.Worksheets[ ( i = ; i < ; i++ ( j = ; j < ; j++ ws.Cells.Rows[i][j].Value = (i + ) + + (j + ) + + (i + ) * (j + wk.Save( Console.WriteLine( Console.ReadKey();

产生的Excel文件:

2.读取Excel

DataTable dt = Aspose.Cells.License li = li.SetLicense( Aspose.Cells.Workbook wk = Aspose.Cells.Workbook( Worksheet ws = wk.Worksheets[ dt = ws.Cells.ExportDataTable(,,, ( k = ; k < dt.Rows.Count; k++ ( h = ; h < dt.Columns.Count; h++ Console.Write(dt.Rows[k][h].ToString() + Console.WriteLine( Console.ReadKey();

运行读取的结果: