Пример #1
0
        private int CreateQuotationItemDetailTable(int count, OfficeOpenXml.ExcelWorksheet worksheet, List <QuotationItemDetailDto> quotationItemList)
        {
            var RowNumber = 29;

            for (int i = 0; i < count; i++)
            {
                if (i < quotationItemList.Count)
                {
                    worksheet.Cells[RowNumber, 1, RowNumber, 1].Value = quotationItemList[i].Style;
                    worksheet.Cells[RowNumber, 3, RowNumber, 3].Value = quotationItemList[i].Description;
                    worksheet.Cells[RowNumber, 4, RowNumber, 4].Value = quotationItemList[i].Quantity;
                    worksheet.Cells[RowNumber, 7, RowNumber, 7].Value = quotationItemList[i].UnitPrice;
                }
                RowNumber++;
            }

            var defaultItemrows = 26;

            if (defaultItemrows > quotationItemList.Count)
            {
                worksheet.DeleteRow(56, 973, true);
            }
            else
            {
                var numberOfRowsToDelete = 1029 - (RowNumber + quotationItemList.Count);
                worksheet.DeleteRow(RowNumber + quotationItemList.Count, numberOfRowsToDelete, true);
            }

            return(1);
        }
Пример #2
0
 public static ExcelWorksheet DeleteEndEmptyRows(this ExcelWorksheet ws)
 {
     while (ws.IsEndRowEmpty())
     {
         ws.DeleteRow(ws.Dimension.End.Row, 1);
     }
     return(ws);
 }
Пример #3
0
        private void InsertQuotationItemDetails(int count, OfficeOpenXml.ExcelWorksheet worksheet, List <QuotationItemDetailDto> quotationItemList, bool withDiscount)
        {
            var RowNumber = 29;

            for (int i = 0; i < count; i++)
            {
                if (i < quotationItemList.Count)
                {
                    worksheet.Cells[RowNumber, 1, RowNumber, 1].Value = quotationItemList[i].Style;
                    worksheet.Cells[RowNumber, 3, RowNumber, 3].Value = quotationItemList[i].Description;
                    worksheet.Cells[RowNumber, 4, RowNumber, 4].Value = quotationItemList[i].Quantity;
                    if (withDiscount)
                    {
                        worksheet.Cells[RowNumber, 7, RowNumber, 7].Value = quotationItemList[i].UnitPrice;
                    }
                    else
                    {
                        worksheet.Cells[RowNumber, 5, RowNumber, 5].Value = quotationItemList[i].UnitPrice;
                    }
                }
                RowNumber++;
            }

            var defaultItemrows = 26;

            if (defaultItemrows > quotationItemList.Count)
            {
                var deleteFrom = 56;
                worksheet.DeleteRow(deleteFrom, 973, true);
            }
            else
            {
                var numberOfRowsToDelete = 974 - (quotationItemList.Count - defaultItemrows);
                worksheet.DeleteRow(RowNumber, numberOfRowsToDelete, true);
            }
        }