コード例 #1
0
        public static void PrintCellsValue <T>(this IXLWorksheet worksheet, T model, int printedRow, int totalColumns, int?indexRow = null, int printedColumn = 2)
        {
            var myType = model.GetType();
            var props  = new List <PropertyInfo>(myType.GetProperties());

            worksheet.GenerateRowAndStyling(printedRow, totalColumns);
            if (indexRow != null)
            {
                worksheet.Cell(printedRow, 1).Value = indexRow;
            }

            var j = printedColumn;

            foreach (var propValue in props.Select(prop => prop.GetValue(model, null)))
            {
                // ignore index column
                worksheet.Cell(printedRow, j).Value = propValue;
                j++;
            }
            System.Threading.Thread.Sleep(300);
        }