Vue3实现动态导入Excel表格数据( 三 )

然后处理前端传过来的数据转换成需要的数据,这里type需要修改成枚举类型,类型可以根据需求进行扩展 /// <summary>/// 处理前端传过来的数据/// </summary>/// <param name="companiesInput"></param>private void ProcessingData(GenerateCheckTemplate companiesInput, DataTable dataTable){Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();foreach (var data in companiesInput.tempData){DataRow dataRow = dataTable.NewRow();foreach (Correspondence correspondence in companiesInput.SelectData){if (correspondence.type == "0"){dataRow[correspondence.key] = correspondence.value;}else if (correspondence.type == "1"){dataRow[correspondence.key] = data[correspondence.selectValue];}else if (correspondence.type == "2"){string value = https://www.huyubaike.com/biancheng/data[correspondence.selectValue];if (keyValuePairs.ContainsKey(value)){dataRow[correspondence.key] = keyValuePairs[value];}else{keyValuePairs.Add(value, (keyValuePairs.Count + 1).ToString().PadLeft(2,'0'));dataRow[correspondence.key] = keyValuePairs[value];}}}dataTable.Rows.Add(dataRow);}}整体的功能到这里基本上实现了,具体的细节可能需要根据不同的项目进行优化,有更多的方案可以一起进行交流附上源码地址:https://gitee.com/wyf854861085/file-upload.git

推荐阅读