再次调整

parent 13d40beb
......@@ -2,6 +2,12 @@
namespace Performance.Services.OnlineExcel
{
public class EpColumn
{
public int row { get; set; }
public int col { get; set; }
public string renderer { get; set; }
}
/// <summary>
/// 单元格Class
/// </summary>
......@@ -10,7 +16,8 @@ public class EpCellClass
private List<string> _className;
public int row { get; set; }
public int col { get; set; }
public string renderer;
public bool editor { get; set; }
public string className
{
get
......
namespace Performance.Services.OnlineExcel
using System.Collections.Generic;
namespace Performance.Services.OnlineExcel
{
/// <summary>
/// 加载Excel汇总信息
/// </summary>
public class EpSheet
{
public object renders { get; set; }
public object mergeCells { get; set; }
public object data { get; set; }
public object cell { get; set; }
......
......@@ -81,6 +81,9 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
}
}
}
sheetNames = sheetNames
.OrderBy(w => w.SheetType == SheetType.Unidentifiable ? 1 : 0).ToList();
_cache.Set(key, sheetNames, absoluteExpirationRelativeToNow);
return sheetNames;
......@@ -113,6 +116,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
List<Dictionary<string, object>> datas = new List<Dictionary<string, object>>();
List<EpCellClass> cells = new List<EpCellClass>();
List<EpColumn> renders = new List<EpColumn>();
for (int row = 1, n = sheet.Dimension.End.Row; row <= n; row++)
{
......@@ -130,6 +134,10 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
var cellStyle = GetCellClass(cell, row, col);
if (cellStyle != null)
cells.Add(cellStyle);
var render = GetCellRender(cell, row, col);
if (render != null)
renders.Add(render);
}
datas.Add(data);
}
......@@ -140,6 +148,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
cell = cells,
colWidths = colWidths,
data = datas,
renders = renders,
mergeCells = mergeCells,
};
_cache.Set(key, epSheet, absoluteExpirationRelativeToNow);
......@@ -201,47 +210,66 @@ private static List<double> GetColWidths(ExcelWorksheet sheet)
return colWidths;
}
/// <summary>
/// 读取类Class
/// 读取单元格渲染方式
/// </summary>
/// <param name="cell"></param>
/// <param name="row"></param>
/// <param name="col"></param>
/// <returns></returns>
private EpCellClass GetCellClass(ExcelRange cell, int row, int col)
private EpColumn GetCellRender(ExcelRange cell, int row, int col)
{
var cellStyle = new EpCellClass
var column = new EpColumn
{
row = row - 1,
col = col - 1
col = col - 1,
};
if (cell.Value is ExcelErrorValue)
{
cellStyle.renderer = "customExcelErrorValueStylesRenderer";
column.renderer = "customExcelErrorValueStylesRenderer";
}
else if (!string.IsNullOrEmpty(cell.Formula))
{
cellStyle.renderer = "customFormulaStylesRenderer";
column.renderer = "customFormulaStylesRenderer";
}
else if (cell.Style.Border.Top.Style != ExcelBorderStyle.None
|| cell.Style.Border.Bottom.Style != ExcelBorderStyle.None
|| cell.Style.Border.Left.Style != ExcelBorderStyle.None
|| cell.Style.Border.Right.Style != ExcelBorderStyle.None)
{
cellStyle.renderer = "customExcelBorderStylesRenderer";
column.renderer = "customExcelBorderStylesRenderer";
}
if (HorizontalMapps.ContainsKey(cell.Style.HorizontalAlignment.ToString()))
{
cellStyle.AddClassName(HorizontalMapps[cell.Style.HorizontalAlignment.ToString()]);
}
if (VerticalMapps.ContainsKey(cell.Style.VerticalAlignment.ToString()))
{
cellStyle.AddClassName(VerticalMapps[cell.Style.VerticalAlignment.ToString()]);
}
if (string.IsNullOrEmpty(cellStyle.renderer) && string.IsNullOrEmpty(cellStyle.className))
if (string.IsNullOrEmpty(column.renderer))
return null;
return column;
}
/// <summary>
/// 读取类Class
/// </summary>
/// <param name="cell"></param>
/// <param name="row"></param>
/// <param name="col"></param>
/// <returns></returns>
private EpCellClass GetCellClass(ExcelRange cell, int row, int col)
{
var cellStyle = new EpCellClass
{
row = row - 1,
col = col - 1,
editor = false
};
//if (HorizontalMapps.ContainsKey(cell.Style.HorizontalAlignment.ToString()))
//{
// cellStyle.AddClassName(HorizontalMapps[cell.Style.HorizontalAlignment.ToString()]);
//}
//if (VerticalMapps.ContainsKey(cell.Style.VerticalAlignment.ToString()))
//{
// cellStyle.AddClassName(VerticalMapps[cell.Style.VerticalAlignment.ToString()]);
//}
cellStyle.AddClassName("htCenter");
cellStyle.AddClassName("htMiddle");
return cellStyle;
}
/// <summary>
......@@ -251,7 +279,8 @@ private EpCellClass GetCellClass(ExcelRange cell, int row, int col)
/// <returns></returns>
private object GetCellValue(ExcelRange cell)
{
return (cell.Value is ExcelErrorValue || !string.IsNullOrEmpty(cell.Formula)) ? cell.Text : cell.Value;
//return (cell.Value is ExcelErrorValue || !string.IsNullOrEmpty(cell.Formula)) ? cell.Text : cell.Value;
return cell.Text;
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment