Beispiel #1
0
        public byte[] Export <T>(ExportOption <T> exportOption)
            where T : class, new()
        {
            IWorkbook workbook = null;

            if (exportOption.ExportType == ExportType.XLS)
            {
                workbook = new HSSFWorkbook();
            }
            else
            {
                workbook = new XSSFWorkbook();
            }

            ISheet sheet = workbook.CreateSheet(exportOption.SheetName);

            var headerDict = ExportMappingDictFactory.CreateInstance(typeof(T));

            SetHeader <T>(sheet, exportOption.HeaderRowIndex, headerDict);

            if (exportOption.Data != null && exportOption.Data.Count > 0)
            {
                SetDataRows(sheet, exportOption.DataRowStartIndex, exportOption.Data, headerDict);
            }

            return(workbook?.ToBytes());
        }
Beispiel #2
0
        public byte[] Export <T>(ExportOption <T> exportOption) where T : class, new()
        {
            //var dt = ToDataTable(exportOption.Data);
            //DataSet ds = new DataSet();

            //ds.Tables.Add(dt);

            var headerDict = ExportMappingDictFactory.CreateInstance(typeof(T));

            return(Export(exportOption.Data, headerDict));
        }