领胜LDS 键盘AOI检测项目
xcd
2020-07-15 d3a44f202c0b12cbac67c71129c3c4f480df55b9
src/Bro.M071.DBManager/ExcelExportHelper.cs
@@ -12,20 +12,23 @@
    public class ExcelExportSet
    {
        public List<string> Worksheets { get; set; }
        public List<string> Worksheets { get; set; } = new List<string>();
        /// <summary>
        /// Key: Worksheet的名称 Value:Worksheet对应的列名集合(key 为要导出的列名 value 为导出后显示的列名)
        /// </summary>
        public Dictionary<string, Dictionary<string, string>> WorksheetColumns { get; set; }
        public Dictionary<string, DataTable> WorksheetDataTable { get; set; }
        public Dictionary<string, Dictionary<string, string>> WorksheetColumns { get; set; } = new Dictionary<string, Dictionary<string, string>>();
        public ExcelExportSet()
        {
            Worksheets = new List<string>();
            WorksheetColumns = new Dictionary<string, Dictionary<string, string>>();
            WorksheetDataTable = new Dictionary<string, DataTable>();
        }
        public Dictionary<string, Dictionary<string, string>> WorksheetRows { get; set; } = new Dictionary<string, Dictionary<string, string>>();
        public Dictionary<string, DataTable> WorksheetDataTable { get; set; } = new Dictionary<string, DataTable>();
        //public ExcelExportSet()
        //{
        //    Worksheets = new List<string>();
        //    WorksheetColumns = new Dictionary<string, Dictionary<string, string>>();
        //    WorksheetDataTable = new Dictionary<string, DataTable>();
        //}
    }
@@ -107,7 +110,7 @@
                    {
                        // autofit width of cells with small content 
                        ExcelRange columnCells = workSheet.Cells[workSheet.Dimension.Start.Row, columnIndex, workSheet.Dimension.End.Row, columnIndex];
                        int maxLength = columnCells.Max(cell => cell.Value.ToString().Count());
                        int maxLength = columnCells.Max(cell => (cell.Value ?? "").ToString().Count());
                        if (maxLength < 150)
                        {
                            workSheet.Column(columnIndex).AutoFit();
@@ -258,13 +261,14 @@
        {
            try
            {
                return obj.ToString();
                return (obj ?? "").ToString();
            }
            catch (Exception)
            {
                return "";
            }
        }
    }
}