excel导入
This commit is contained in:
parent
d791fa37c1
commit
e697d009bf
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MineTec.ProManager.GalleryFiles.Dto
|
||||||
|
{
|
||||||
|
public class PatternExcelImportDto
|
||||||
|
{
|
||||||
|
public string msg { get; set; } //提示信息
|
||||||
|
|
||||||
|
public string result { get; set; } //导入结果
|
||||||
|
|
||||||
|
public string index { get; set; } //序号
|
||||||
|
|
||||||
|
public string importmode { get; set; } //导入模式
|
||||||
|
|
||||||
|
public string filenum { get; set; }//图纸编号
|
||||||
|
|
||||||
|
public string projectnum { get; set; }//项目编号
|
||||||
|
|
||||||
|
public int patterntype { get; set; }//图样类型
|
||||||
|
|
||||||
|
public string signaturecode { get; set; } //特征码
|
||||||
|
|
||||||
|
public string subcode { get; set; } //附加尾号
|
||||||
|
|
||||||
|
public string filename { get; set; } //图样名称
|
||||||
|
|
||||||
|
public string pictureframe { get; set; } //图幅
|
||||||
|
|
||||||
|
public string remark { get; set; } //备注
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using MineTec.ProManager.Commd;
|
using MineTec.ProManager.Commd;
|
||||||
using MineTec.ProManager.FileStore.Dto;
|
using MineTec.ProManager.FileStore.Dto;
|
||||||
using MineTec.ProManager.GalleryFiles.Dto;
|
using MineTec.ProManager.GalleryFiles.Dto;
|
||||||
|
using OfficeOpenXml;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -272,5 +273,38 @@ namespace MineTec.ProManager.GalleryFiles
|
|||||||
var url = $@"\{uploadPath}\{dirPath}";
|
var url = $@"\{uploadPath}\{dirPath}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//导入
|
||||||
|
public OutputBase Excel(IFormFile file)
|
||||||
|
{
|
||||||
|
var result = new OutputBase();
|
||||||
|
|
||||||
|
Stream stream = file.OpenReadStream();
|
||||||
|
using (var package = new ExcelPackage(stream))
|
||||||
|
{
|
||||||
|
// 获取Exel指定工作簿,"Sheet1"也可以用索引代替
|
||||||
|
ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"];
|
||||||
|
// 获取数据行数
|
||||||
|
int RowNum = worksheet.Dimension.Rows;
|
||||||
|
// 待处理数据存储列表
|
||||||
|
List<PatternExcelImportDto> ExcelData = new List<PatternExcelImportDto>();
|
||||||
|
// 获取每行数据
|
||||||
|
for (int row = 1; row <= RowNum; row++)
|
||||||
|
{
|
||||||
|
ExcelData.Add(new PatternExcelImportDto
|
||||||
|
{
|
||||||
|
// 获取每列数据
|
||||||
|
Account = worksheet.Cells[row, 1].Value.ToString(),
|
||||||
|
Password = worksheet.Cells[row, 2].Value.ToString(),
|
||||||
|
Name = worksheet.Cells[row, 3].Value.ToString(),
|
||||||
|
Sex = worksheet.Cells[row, 4].Value.ToString(),
|
||||||
|
UserRole = worksheet.Cells[row, 5].Value.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,6 +10,9 @@
|
|||||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||||
<RootNamespace>MineTec.ProManager</RootNamespace>
|
<RootNamespace>MineTec.ProManager</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EPPlus" Version="5.8.2" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MineTec.ProManager.Core\MineTec.ProManager.Core.csproj" />
|
<ProjectReference Include="..\MineTec.ProManager.Core\MineTec.ProManager.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user