Ejemplo n.º 1
0
        private static void SaveOneGroupTestInfo(UserInfoMode userInfo, GroupTestInfo groupTestInfo, Cells cells,
                                                 int startRow)
        {
            int columnIndex = 0;

            //记录用户信息
            cells[startRow, columnIndex++].Value = userInfo.TestCode;
            cells[startRow, columnIndex++].Value = userInfo.UserName;
            cells[startRow, columnIndex++].Value = userInfo.Age;
            cells[startRow, columnIndex++].Value = userInfo.TestDate.ToString("yyyy-MM-dd");

            //记录记忆信息
            SavePicturesUserTestInfoByStep(cells, startRow, ref columnIndex, groupTestInfo.FourPicturesUserTestRecordInfo);
            SavePicturesUserTestInfoByStep(cells, startRow, ref columnIndex, groupTestInfo.FivePicturesUserTestRecordInfo);
            SavePicturesUserTestInfoByStep(cells, startRow, ref columnIndex, groupTestInfo.SixPicturesUserTestRecordInfo);
        }
Ejemplo n.º 2
0
 public static void SaveMemoryTestData(UserInfoMode userInfo, GroupTestInfo groupTestInfo)
 {
     if (GetExcelPath(out var excelPath))
     {
         try
         {
             Workbook workbook          = new Workbook(excelPath);
             var      workbookWorksheet = workbook.Worksheets[0];
             Cells    cells             = workbookWorksheet.Cells;
             var      startRow          = cells.MaxDataRow + 1;
             SaveOneGroupTestInfo(userInfo, groupTestInfo, cells, startRow++);
             workbookWorksheet.AutoFitColumns(); //自适应宽
             workbook.Save(excelPath, SaveFormat.Auto);
         }
         catch (Exception e)
         {
             MessageBox.Show($"{e.Message}\r\n导出到Excel异常,请确认是Excel状态是否正常!");
         }
     }
 }