2022年度甬江杯投票系统

This commit is contained in:
范露尧
2022-10-19 20:30:10 +08:00
parent a8fa2ceb75
commit 7e59e7d873
8 changed files with 398 additions and 258 deletions

View File

@@ -117,7 +117,7 @@ namespace Vote.Services.Tools
{
try
{
string template_name = "2021年度甬江杯投票.xlsx";
string template_name = "2022年度甬江杯投票.xlsx";
string excelFilePath = $"{App.WebHostEnvironment.WebRootPath}\\ExcelTemplate\\{template_name}";
string outputPath = string.Empty;
if (!string.IsNullOrEmpty(excelFilePath))
@@ -127,7 +127,7 @@ namespace Vote.Services.Tools
bool isCompatible = ExcelHelper.GetIsCompatible(excelFilePath);
IWorkbook workbook = ExcelHelper.CreateWorkbook(isCompatible, excelFileStream);
ISheet sheet = null;
sheet = workbook.GetSheetAt(1);
sheet = workbook.GetSheetAt(0);
Dictionary<string, string> dic_sheet_config = new Dictionary<string, string>();
var data = GetDataByType(list, Entities.EnumProjectType.FangJian);
//从第几行开始 , 比如 行号是4 , 就写3
@@ -144,7 +144,7 @@ namespace Vote.Services.Tools
data = GetDataByType(list, Entities.EnumProjectType.ShiZheng);
for (int i = 0; i < data.Count; i++)
{
var c_rowindex = length0 + 1 + startRowIndex + i;
var c_rowindex = length0 + (length0 > 0 ? 1 : 0) + startRowIndex + i;
int cell_start_index = start_column.ToExcelColumnIndex();
sheet.GetRow(c_rowindex).GetCell(cell_start_index).SetCellValue(data[i].no_count);
sheet.GetRow(c_rowindex).GetCell(cell_start_index + 1).SetCellValue(data[i].yes_count);
@@ -154,7 +154,7 @@ namespace Vote.Services.Tools
data = GetDataByType(list, Entities.EnumProjectType.GuiDaoGongCheng);
for (int i = 0; i < data.Count; i++)
{
var c_rowindex = length0 + 1 + length1 + 1 + startRowIndex + i;
var c_rowindex = length0 + (length0 > 0 ? 1 : 0) + length1 + (length1 > 0 ? 1 : 0) + startRowIndex + i;
int cell_start_index = start_column.ToExcelColumnIndex();
sheet.GetRow(c_rowindex).GetCell(cell_start_index).SetCellValue(data[i].no_count);
sheet.GetRow(c_rowindex).GetCell(cell_start_index + 1).SetCellValue(data[i].yes_count);
@@ -164,7 +164,7 @@ namespace Vote.Services.Tools
data = GetDataByType(list, Entities.EnumProjectType.DianLiGongCheng);
for (int i = 0; i < data.Count; i++)
{
var c_rowindex = length0 + 1 + length1 + 1 + length2 + 1 + startRowIndex + i;
var c_rowindex = length0 + (length0 > 0 ? 1 : 0) + length1 + (length1 > 0 ? 1 : 0) + length2 + (length2 > 0 ? 1 : 0) + startRowIndex + i;
int cell_start_index = start_column.ToExcelColumnIndex();
sheet.GetRow(c_rowindex).GetCell(cell_start_index).SetCellValue(data[i].no_count);
sheet.GetRow(c_rowindex).GetCell(cell_start_index + 1).SetCellValue(data[i].yes_count);
@@ -174,7 +174,7 @@ namespace Vote.Services.Tools
data = GetDataByType(list, Entities.EnumProjectType.JiaoTongGongCheng);
for (int i = 0; i < data.Count; i++)
{
var c_rowindex = length0 + 1 + length1 + 1 + length2 + 1 + length3 + 1 + startRowIndex + i;
var c_rowindex = length0 + (length0 > 0 ? 1 : 0) + length1 + (length1 > 0 ? 1 : 0) + length2 + (length2 > 0 ? 1 : 0) + length3 + (length3 > 0 ? 1 : 0) + startRowIndex + i;
int cell_start_index = start_column.ToExcelColumnIndex();
sheet.GetRow(c_rowindex).GetCell(cell_start_index).SetCellValue(data[i].no_count);
sheet.GetRow(c_rowindex).GetCell(cell_start_index + 1).SetCellValue(data[i].yes_count);
@@ -184,7 +184,7 @@ namespace Vote.Services.Tools
data = GetDataByType(list, Entities.EnumProjectType.ShuiLiGongCheng);
for (int i = 0; i < data.Count; i++)
{
var c_rowindex = length0 + 1 + length1 + 1 + length2 + 1 + length3 + 1 + length4 + 1 + startRowIndex + i;
var c_rowindex = length0 + (length0 > 0 ? 1 : 0) + length1 + (length1 > 0 ? 1 : 0) + length2 + (length2 > 0 ? 1 : 0) + length3 + (length3 > 0 ? 1 : 0) + length4 + (length4 > 0 ? 1 : 0) + startRowIndex + i;
int cell_start_index = start_column.ToExcelColumnIndex();
sheet.GetRow(c_rowindex).GetCell(cell_start_index).SetCellValue(data[i].no_count);
sheet.GetRow(c_rowindex).GetCell(cell_start_index + 1).SetCellValue(data[i].yes_count);
@@ -194,7 +194,7 @@ namespace Vote.Services.Tools
var savePath = file.DirectoryName + "\\OutPut\\";
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
outputPath = savePath + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + template_name;
outputPath = savePath + DateTime.Now.ToString("yyyyMMddHHmmsss") + "-" + template_name;
using (var filess = new FileStream(outputPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
workbook.Write(filess);