# Soul.XLS **Repository Path**: zdwwym/Soul.XLS ## Basic Information - **Project Name**: Soul.XLS - **Description**: 基于spire.xls扩展增强 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-10-28 - **Last Updated**: 2024-10-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ```C# public static void TestWriter() { var columns = new ExcelColumnCollection("学生信息") { new ExcelColumn("学生信息") { Items = new [] { new ExcelColumn("个人信息") { Items = new [] { new ExcelColumn("姓名"), new ExcelColumn("生日", style => { style.ColumnWidth = 14; style.Alignment = HorizontalAlignment.Center; }), } }, new ExcelColumn("家庭信息") { Items = new [] { new ExcelColumn("地址"), new ExcelColumn("电话"), } }, } }, new ExcelColumn("成绩") { Items = new [] { new ExcelColumn("文综") { Items = new [] { new ExcelColumn("语文"), new ExcelColumn("历史"), } }, new ExcelColumn("理综") { Items = new [] { new ExcelColumn("数学",style=> { style.Format = "0.00"; }), new ExcelColumn("物理"), } } } } }; var table1 = new ExcelTable("学生信息", columns); table1.FreezePanes(4, 1); for (int i = 0; i < 100; i++) { var row = table1.NewRow(); row["姓名"] = "花间岛"; row["生日"] = DateTime.Now.ToString(); row["地址"] = "浙江杭州"; row["电话"] = "10086"; row["语文"] = 100; row["历史"] = 50; row["数学"] = 99; row["物理"] = 97; table1.Rows.Add(row); } var table2 = new ExcelTable("消费信息", new ExcelColumnCollection("消费信息") { new ExcelColumn("商品",style=> { style.Alignment = HorizontalAlignment.Center; }), new ExcelColumn("价格"), }); for (int i = 0; i < 100; i++) { var row = table2.NewRow(); row["商品"] = "哇哈哈"; row["价格"] = 15.2; table2.Rows.Add(row); } var workbook = new ExcelWorkbook(); workbook.Tables.Add(table1); workbook.Tables.Add(table2); workbook.SaveToFile("D:\\ff.xlsx", ExcelFileType.Xlsx); } public static void TestReader() { var workbook = new ExcelWorkbook(); workbook.LoadFormFile("D:\\ff.xlsx"); var sheet = workbook.GetSheet(0); var table = workbook.ExportTable(0, 1, 9); foreach (var item in table.Rows) { var a1 = item.GetValue("语文"); var a2 = item.GetValue("历史"); var a3 = item.GetValue("数学"); var a4 = item.GetValue("生日"); } } ``` ![](./images/test.png)