using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Aspose.Cells;
using System.Drawing;
using System.Data;
using System.Reflection;
namespace EMIS.Utility
{
public class NumberMergeModel {
public int first;
public int last;
public string mes;
}
public class ReportHelper
{
string baseFilePath = "~/Config/Report/";
public string GetReportSql(string fileName)
{
string fullPath = baseFilePath + fileName.TrimStart('/');
var physicalFullPath = System.Web.HttpContext.Current.Server.MapPath(fullPath);
var sqlText=File.ReadAllText(physicalFullPath, Encoding.UTF8);
return sqlText;
}
public Workbook GetReportTemple(string fileName) {
string fullPath = baseFilePath + fileName.TrimStart('/');
var physicalFullPath = System.Web.HttpContext.Current.Server.MapPath(fullPath);
Workbook wb = new Workbook(physicalFullPath);
return wb;
}
public Style BuildBorderStyle(Workbook wk) {
var style = wk.CreateStyle();
style.VerticalAlignment = TextAlignmentType.Center;
style.HorizontalAlignment = TextAlignmentType.Center;
style.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.TopBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.BottomBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
return style;
}
public Style BuildBorderStyleAndSize(Workbook wk)
{
var style = wk.CreateStyle();
style.VerticalAlignment = TextAlignmentType.Center;
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Size = 18;//文字大小
style.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.TopBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.BottomBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
style.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
return style;
}
///
/// 连续数字合并
///
///
///
public string SetNumberMerge(List array) {
List texts = new List();
var array1 = array.Distinct().OrderBy(a => a).ToList();
if (array1.Count < 3) {
return string.Join(",", array1.Select(s=>s.ToString()).ToArray());
}
int first = array1.First(), last = array1.First();
for (int i = 1; i