通用Excel模板下载

master
xiaochanghai 5 months ago
parent c441d2dad5
commit f6bc1af902
  1. 7
      Model/Tiobon.Web.pdm
  2. 7
      Tiobon.Core.Common/Helper/NPOIHelper.cs
  3. 385
      Tiobon.Core.DataAccess/ReportHelper.cs
  4. 219
      Tiobon.Core.Services/Ghrh/Ghrh_HumanRequestServices.cs

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{C294868A-C3F3-41AD-98CC-78B6D4E0CC40}" Label="" LastModificationDate="1736228344" Name="Tiobon" Objects="2781" Symbols="104" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.0.0.2613"?>
<?PowerDesigner AppLocale="UTF16" ID="{C294868A-C3F3-41AD-98CC-78B6D4E0CC40}" Label="" LastModificationDate="1736402568" Name="Tiobon" Objects="2781" Symbols="104" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.0.0.2613"?>
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -13684,10 +13684,11 @@ LABL 0 Arial Unicode MS,8,N</a:FontList>
<a:Code>CourseClassId</a:Code>
<a:CreationDate>1714100442</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1714107704</a:ModificationDate>
<a:ModificationDate>1736402568</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>课程分类ID</a:Comment>
<a:DataType>bigint</a:DataType>
<a:DataType>nvarchar(2000)</a:DataType>
<a:Length>2000</a:Length>
</o:Column>
<o:Column Id="o297">
<a:ObjectID>C7365459-E3F3-49CA-8372-60D1FCEDF4A0</a:ObjectID>

@ -1,10 +1,9 @@
using System.Data;
using System.Text;
using NPOI.HPSF;
using NPOI.HPSF;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using OfficeOpenXml.Drawing;
using System.Data;
using System.Text;
namespace Tiobon.Core.Common.Helper;

@ -1,4 +1,11 @@
using System;

using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Spreadsheet;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -7,12 +14,6 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Spreadsheet;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using SqlSugar;
using Tiobon.Core.Common;
using Tiobon.Core.Common.Extensions;
using Tiobon.Core.Model.Models;
@ -107,6 +108,296 @@ public static class ReportHelper
public static async Task<string> ImportTemplate(ISqlSugarClient Db, List<QueryExportColumn> tableColumn, DataTable dt, string menuName)
{
//生成表格
try
{
//生成文件至文件服务器
var fid = SnowFlakeSingle.Instance.NextId();
var filepath = $"{$"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}import{Path.DirectorySeparatorChar}{fid}{Path.DirectorySeparatorChar}"}";
if (!Directory.Exists(filepath))
Directory.CreateDirectory(filepath);
var fname = $"{menuName}.xlsx";
var sheetName = "导入数据";
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet = workbook.CreateSheet(sheetName);
ICellStyle dateStyle = workbook.CreateCellStyle();
IDataFormat format = workbook.CreateDataFormat();
dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
ICellStyle datetimeStyle = workbook.CreateCellStyle();
datetimeStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm");
ICellStyle datetimesStyle = workbook.CreateCellStyle();
datetimesStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm:ss");
int[] arrColWidth = new int[tableColumn.Count];
for (int i = 0; i < tableColumn.Count; i++)
{
arrColWidth[i] = Encoding.GetEncoding("utf-8").GetBytes(tableColumn[i].label).Length;
}
for (int i = 0; i < 1; i++)
{
for (int j = 0; j < tableColumn.Count; j++)
{
int intTemp = Encoding.GetEncoding("utf-8").GetBytes(tableColumn[j].label).Length;
if (intTemp > arrColWidth[j])
{
arrColWidth[j] = intTemp;
}
}
}
int rowIndex = 0;
int intTop = 0;
int HeightInPoints = 40;
int listColIndex = 0;
//foreach (DataRow row1 in dt.Rows)
//{
//}
#region 新建表、填充表头、填充列头,样式
if (rowIndex == 655350 || rowIndex == 0)
{
if (rowIndex != 0)
{
sheet = workbook.CreateSheet();
}
intTop = 0;
#region 列头及样式
{
IRow headerRow = sheet.CreateRow(intTop);
headerRow.HeightInPoints = HeightInPoints;
intTop += 1;
ICellStyle headStyle = workbook.CreateCellStyle();
headStyle.Alignment = HorizontalAlignment.Center; //居中
headStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
headStyle.WrapText = true;//自动换行
// 边框
headStyle.BorderBottom = BorderStyle.Thin;
headStyle.BorderLeft = BorderStyle.Thin;
headStyle.BorderRight = BorderStyle.Thin;
headStyle.BorderTop = BorderStyle.Thin;
ICellStyle headRequiredStyle = workbook.CreateCellStyle();
headRequiredStyle.Alignment = HorizontalAlignment.Center; //居中
headRequiredStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
headRequiredStyle.WrapText = true;//自动换行
// 边框
headRequiredStyle.BorderBottom = BorderStyle.Thin;
headRequiredStyle.BorderLeft = BorderStyle.Thin;
headRequiredStyle.BorderRight = BorderStyle.Thin;
headRequiredStyle.BorderTop = BorderStyle.Thin;
// 字体
IFont font = workbook.CreateFont();
font.FontHeightInPoints = (short)10;
font.IsBold = true;
font.FontName = "宋体";
headStyle.SetFont(font);
IFont font2 = workbook.CreateFont();
font2.FontHeightInPoints = (short)10;
font2.IsBold = true;
font2.FontName = "宋体";
font2.Color = IndexedColors.Red.Index;
headRequiredStyle.SetFont(font2);
//ICellStyle headStyle = workbook.CreateCellStyle();
//headStyle.Alignment = HorizontalAlignment.Center;
//headStyle.BorderBottom = BorderStyle.Medium;
//headStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.LightGreen.Index;
//headStyle.FillPattern = FillPattern.NoFill;
//IFont font = workbook.CreateFont();
//font.Boldweight = 700;
//headStyle.SetFont(font);
for (int j = 0; j < tableColumn.Count; j++)
{
string dataSource = tableColumn[j].dataSource;
string field = tableColumn[j].field;
string label = tableColumn[j].label;
headerRow.CreateCell(j).SetCellValue(label);
if (tableColumn[j].required == "true")
headerRow.GetCell(j).CellStyle = headRequiredStyle;
else
headerRow.GetCell(j).CellStyle = headStyle;
//设置列宽
//sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
if (arrColWidth[j] > 255)
{
arrColWidth[j] = 254;
}
else
{
sheet.SetColumnWidth(j, (arrColWidth[j] + 1) * 256);
}
//是否下拉
if (!string.IsNullOrEmpty(dataSource)
&& !dataSource.StartsWith("OrgTreeWith")
&& !dataSource.StartsWith("StaffWith")
)
{
var dataSourceLists = GetDataSourceLists(Db, field, dataSource);
var fields = new List<string>()
{
"InOrOut",
"ResumeType",
"ImportanceDegree",
"YearHumanId",
"TitleId"
};
try
{
if (dataSourceLists.Any() && fields.Contains(field))
{
//设置数据源的值
IDataValidationConstraint dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(dataSourceLists.Where(x => x.name.IsNotEmptyOrNull()).Select(x => x.name).ToArray());
//设置编辑的区域
IDataValidation dataValidation1 = sheet.GetDataValidationHelper().CreateValidation(dvConstraint1, new CellRangeAddressList(1, 65535, j, j));
sheet.AddValidationData(dataValidation1);
}
}
catch (Exception E)
{
}
// 多选 ,自行输入不报错
//if (drow.elementType.ToString().LastIndexOf("multiple") == -1)
//{
// dataValidate.CreateErrorBox("输入不合法", "请输入或选择下拉列表中的值。");
// dataValidate.ShowPromptBox = true;
//}
//else
//{
// dataValidate.ShowErrorBox = false;
//}
}
}
}
#endregion
rowIndex = intTop;
}
#endregion
#region 填充内容
IRow dataRow = sheet.CreateRow(rowIndex);
dataRow.HeightInPoints = 25;
ICellStyle style = workbook.CreateCellStyle();
style.Alignment = HorizontalAlignment.Center; //居中
style.VerticalAlignment = VerticalAlignment.Center;//垂直居中
style.WrapText = true;//自动换行
// 边框
style.BorderBottom = BorderStyle.Thin;
style.BorderLeft = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
style.BorderTop = BorderStyle.Thin;
// 字体
var font1 = workbook.CreateFont();
font1.FontHeightInPoints = (short)10;
font1.FontName = "宋体";
style.SetFont(font1);
#endregion
for (int j = 0; j < tableColumn.Count; j++)
{
//设置列宽
//sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
if (arrColWidth[j] > 255)
{
arrColWidth[j] = 254;
}
else
{
sheet.SetColumnWidth(j, (arrColWidth[j] + 1) * 256);
}
}
//rowIndex++;
for (int columnNum = 0; columnNum <= tableColumn.Count; columnNum++)
{
sheet.AutoSizeColumn(columnNum);//先来个常规自适应
var columnWidth = sheet.GetColumnWidth(columnNum) / 256;
for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
{
IRow currentRow;
//当前行未被使用过
if (sheet.GetRow(rowNum) == null)
{
currentRow = sheet.CreateRow(rowNum);
}
else
{
currentRow = sheet.GetRow(rowNum);
}
if (currentRow.GetCell(columnNum) != null)
{
ICell currentCell = currentRow.GetCell(columnNum);
int length = Encoding.Default.GetBytes(currentCell.ToString()).Length;
if (columnWidth < length)
{
columnWidth = length;
if (columnWidth > 30) columnWidth = 30;
}
}
}
try
{
sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256
}
catch (Exception e)
{
}
}
for (int rowNum = 2; rowNum <= sheet.LastRowNum; rowNum++)
{
IRow currentRow = sheet.GetRow(rowNum);
int length = 25;
foreach (var item in currentRow.Cells)
{
if (item != null)
length = Encoding.UTF8.GetBytes(item.ToString()).Length > length ? Encoding.UTF8.GetBytes(item.ToString()).Length : length;
}
currentRow.HeightInPoints = 35 * (length / 150 + 1);
}
//转为字节数组
MemoryStream stream = new MemoryStream();
workbook.Write(stream);
var buf = stream.ToArray();
//保存为Excel文件
using (FileStream fs = new FileStream(filepath + fname, FileMode.Create, FileAccess.Write))
{
fs.Write(buf, 0, buf.Length);
fs.Flush();
}
return filepath + fname;
}
catch (Exception ex)
{
}
return default(string);
}
public static async Task<string> ImportTemplate1(ISqlSugarClient Db, List<QueryExportColumn> tableColumn, DataTable dt, string menuName)
{
//生成表格
@ -140,19 +431,35 @@ public static class ReportHelper
//隐藏下拉数据Sheet
//fileWorkbook.SetSheetHidden(fileWorkbook.GetSheetIndex("下拉数据"), SheetState.Hidden);
IRow erow_1 = sheet.CreateRow(0); //ID行
IRow erow_2 = sheet.CreateRow(1); //文本行
IRow headerRow = sheet.CreateRow(0); //文本行
erow_1.CreateCell(0).SetCellValue("ExcelNums");
erow_2.CreateCell(0).SetCellValue("序号");
headerRow.HeightInPoints = 30;
headerRow.CreateCell(0).SetCellValue("序号");
//必填颜色
var CellRed = fileWorkbook.CreateCellStyle(); // 创建单元格样式
IFont Font = fileWorkbook.CreateFont(); // 创建字体
Font.Color = IndexedColors.Red.Index; // 选择字体颜色
CellRed.SetFont(Font); // 把字体赋给样式
erow_2.GetCell(0).CellStyle = CellRed;
//var CellRed = fileWorkbook.CreateCellStyle(); // 创建单元格样式
//IFont Font = fileWorkbook.CreateFont(); // 创建字体
//Font.Color = IndexedColors.Red.Index; // 选择字体颜色
//CellRed.SetFont(Font); // 把字体赋给样式
ICellStyle headStyle = fileWorkbook.CreateCellStyle();
headStyle.Alignment = HorizontalAlignment.Center; //居中
headStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
headStyle.WrapText = true;//自动换行
// 边框
headStyle.BorderBottom = BorderStyle.Thin;
headStyle.BorderLeft = BorderStyle.Thin;
headStyle.BorderRight = BorderStyle.Thin;
headStyle.BorderTop = BorderStyle.Thin;
// 字体
IFont font = fileWorkbook.CreateFont();
font.FontHeightInPoints = (short)10;
font.IsBold = true;
font.FontName = "宋体";
headStyle.SetFont(font);
headerRow.GetCell(0).CellStyle = headStyle;
//文本类型
ICellStyle cellString = fileWorkbook.CreateCellStyle();
@ -165,10 +472,10 @@ public static class ReportHelper
foreach (var drow in tableColumn)
{
int SortNum = Convert.ToInt32(drow.sortNum);
ICell cell = erow_1.CreateCell(SortNum);
ICell cel2 = erow_2.CreateCell(SortNum);
ICell cel2 = headerRow.CreateCell(SortNum);
string field = drow.field;
;
cel2.CellStyle = headStyle;
string label = drow.label;
// 批注
string commentText = string.Empty;
@ -179,7 +486,6 @@ public static class ReportHelper
catch (Exception)
{
}
cell.SetCellValue(field);
cel2.SetCellValue(label);
// 设置批注
@ -191,7 +497,7 @@ public static class ReportHelper
//是否必填
if (drow.required == "true")
{
cel2.CellStyle = CellRed;
cel2.CellStyle = headStyle;
}
string dataSource = drow.dataSource;
@ -275,21 +581,23 @@ public static class ReportHelper
ColNums = ColNums + 1;
}
erow_1.HeightInPoints = 1;
//erow_1.HeightInPoints = 1;
// 如果导出模板存在默认数据
//if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
for (int i = 0; i < dt.Rows.Count; i++)
{
IRow row1 = sheet.CreateRow(i + 2);
ICell cell = row1.CreateCell(0);
cell.SetCellValue(i + 1);
for (int j = 1; j <= tableColumn.Count; j++)
{
cell = row1.CreateCell(j);
cell.SetCellValue(dt.Rows[i][tableColumn[j - 1].field].ToString());
}
}
//for (int i = 0; i < dt.Rows.Count; i++)
//{
// IRow row1 = sheet.CreateRow(i + 1);
// ICell cell = row1.CreateCell(0);
// cell.SetCellValue(i + 1);
// for (int j = 1; j <= tableColumn.Count; j++)
// {
// cell = row1.CreateCell(j);
// //if (dt.Rows[i][tableColumn[j - 1].field] != null)
// // cell.SetCellValue(dt.Rows[i][tableColumn[j - 1].field].ObjToString());
// }
//}
// Sheet 更改列为自适应宽度
for (int col = 0; col <= ColNums; col++)
@ -421,7 +729,7 @@ public static class ReportHelper
//}
//else
{
string listSQL = string.Format(@"exec[dbo].[PRI_ListValue] '{0}','GetEnableList','',1,63,'',9999,1,2", dataSource);
string listSQL = string.Format(@"exec[dbo].[PRI_ListValue] '{0}','GetEnableList','',1,1,'',9999,1,2", dataSource);
DataSet listds = Db.Ado.GetDataSetAll(listSQL);
if (listds.Tables.Count > 3)
{
@ -449,7 +757,12 @@ public static class ReportHelper
{
}
}
dataSourceList.Add(_dataSource);
var dataSourceStr = string.Join(",", dataSourceList.Select(x => x.name));
if (dataSourceList.Any() && _dataSource.name.IsNotEmptyOrNull())
dataSourceStr = dataSourceStr + "," + _dataSource.name;
if (dataSourceStr.Length <= 255 && _dataSource.name.IsNotEmptyOrNull())
dataSourceList.Add(_dataSource);
}
}
}

@ -1,4 +1,5 @@
using static Tiobon.Core.Model.Consts;
using NPOI.SS.UserModel;
using static Tiobon.Core.Model.Consts;
namespace Tiobon.Core.Services;
@ -529,4 +530,220 @@ WHERE A.IsEnable = 1 AND A.Id = {entitys[i].YearHumanId}");
}
#endregion
//#region Excel导入
//public override async Task<ServiceResult<ExcelData>> ImportExcel(IFormFile file, string menuName = null, long? MasterId = null)
//{
// var data = new ExcelData();
// long id = SnowFlakeSingle.instance.getID();
// var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
// var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}import{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}";
// if (!Directory.Exists(physicsPath + path))
// Directory.CreateDirectory(physicsPath + path);
// var filepath = physicsPath + path + file.FileName;
// using (var stream = File.Create(filepath))
// {
// await file.CopyToAsync(stream);
// }
// string extension = Path.GetExtension(filepath);
// bool isExistError = false;
// var id1 = SnowFlakeSingle.instance.getID();
// string errorFileName = path + SnowFlakeSingle.instance.getID() + extension;
// try
// {
// DataTable dt = NPOIHelper.ImportExcel(filepath, "年度人力配置");
// if (dt.Columns["Comments"] == null)
// dt.Columns.Add("Comments", typeof(string));
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// var comments = new List<string>();
// if (!dt.Columns.Contains("年度"))
// {
// comments.Add("未查询到【年度】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// if (!dt.Columns.Contains("部门"))
// {
// comments.Add("未查询到【部门】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// if (!dt.Columns.Contains("岗位"))
// {
// comments.Add("未查询到【岗位】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// if (!dt.Columns.Contains("职称"))
// {
// comments.Add("未查询到【职称】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// if (!dt.Columns.Contains("职等"))
// {
// comments.Add("未查询到【职等】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// for (int j = 1; j <= 12; j++)
// {
// if (!dt.Columns.Contains(j + "月"))
// {
// comments.Add($"未查询到【{j}月】列!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// }
// var year = dt.Rows[i]["年度"].ToString();
// var deptName = dt.Rows[i]["部门"].ToString();
// var titleName = dt.Rows[i]["岗位"].ToString();
// var jobName = dt.Rows[i]["职称"].ToString();
// var gradeName = dt.Rows[i]["职等"].ToString();
// var dept = await Db.Queryable<Ghro_Dept>().Where(x => x.DeptName == deptName).FirstAsync();
// if (dept == null)
// {
// comments.Add($"无效的部门名称!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// var title = await Db.Queryable<Ghra_Title>().Where(x => x.TitleName == titleName).FirstAsync();
// if (title == null)
// {
// comments.Add($"无效的岗位名称!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// var job = await Db.Queryable<Ghra_Job>().Where(x => x.JobName == jobName).FirstAsync();
// if (job == null)
// {
// comments.Add($"无效的职称名称!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// var grade = await Db.Queryable<Ghra_Grade>().Where(x => x.GradeName == gradeName).FirstAsync();
// if (grade == null)
// {
// comments.Add($"无效的职等名称!");
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// if (1 == 1)
// {
// var dict = new Dictionary<string, object>
// {
// { "Id", SnowFlakeSingle.Instance.NextId() },
// { "CreateBy", App.User.ID },
// { "CreateTime", DateTime.Now },
// { "WorkState", 1 },
// { "Year", year },
// { "DeptId", dept.DeptID },
// { "TitleId", title.TitleID },
// { "GradeId", grade.GradeID },
// { "JobId", job.JobID }
// };
// for (int j = 1; j <= 12; j++)
// dict.Add("M" + j, dt.Rows[i][j + "月"].ToString());
// await Db.Insertable(dict).AS("Ghrh_YearHumanSettings").ExecuteCommandAsync();
// if (comments.Any())
// {
// data.ErrorCount++;
// dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
// isExistError = true;
// continue;
// }
// else
// {
// data.SuccessCount++;
// }
// }
// else
// {
// dt.Rows[i]["Comments"] = "试题在系统中已存在!";
// data.ErrorCount++;
// isExistError = true;
// continue;
// }
// }
// if (isExistError)
// {
// NPOIHelper.ExportExcel(dt, null, "年度人力配置", physicsPath + errorFileName);
// data.filePath = "/Advanced" + errorFileName;
// }
// }
// catch (Exception)
// {
// }
// return ServiceResult<ExcelData>.OprateSuccess("导入成功!", data);
//}
//public override async Task<ServiceResult<string>> DownloadExcel(string menuName)
//{
// var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
// var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}";
// if (!Directory.Exists(physicsPath + path))
// Directory.CreateDirectory(physicsPath + path);
// Type entityType = typeof(Ghrh_YearHumanSettings);
// var fileName = entityType.GetEntityTableName() + ".xlsx";
// //physicsPath = physicsPath + path + fileName;
// IWorkbook hssfworkbook;
// ISheet sheet;
// using (FileStream file = new FileStream(physicsPath + path + fileName, FileMode.Open, FileAccess.Read))
// {
// //hssfworkbook = new HSSFWorkbook(file);
// //hssfworkbook = new XSSFWorkbook(file);
// hssfworkbook = WorkbookFactory.Create(file);
// }
// //ISheet sheet2 = hssfworkbook.CreateSheet("下拉数据");
// var newFileName = Guid.NewGuid() + ".xlsx";
// int listColIndex = 0;
// var physicsPath1 = physicsPath + path + fileName;
// //if (dataSourceLists.Any())
// // physicsPath1 = physicsPath + path + newFileName;
// var result = ServiceResult<string>.OprateSuccess("人力需求维护_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1);
// return result;
//}
//#endregion
}
Loading…
Cancel
Save