Exemplo n.º 1
0
        public void WriteMeeting(ExcelMeetingDataRequest request)
        {
            var sheet = (Worksheet)excelApp.Sheets
                        .First(o => ((Worksheet)o).Name
                               == request.SheetDestination);

            // Write Header
            var header = new List <object> {
                "Name", "Date", "Start", "End"
            };

            var destination = sheet.get_Range("A1", Type.Missing);

            WriteListHorizontally(destination, header);

            // find the next empty cell from column A
            var nextRow = 2;

            if (!string.IsNullOrEmpty(sheet.Cells[2, 1]?.Value?.ToString()))
            {
                var lastCell = sheet.Cells[1, 1].End(XlDirection.xlDown);
                nextRow = lastCell.Row + 1;
            }

            var entry = new List <object>
            {
                request.Data.Name,
                request.Data.Date.Date.ToString("d"),
                request.Data.StartingTime.ToString("hh:mm"),
                request.Data.EndTime.ToString("hh:mm")
            };

            destination = sheet.Cells[nextRow, 1];
            WriteListHorizontally(destination, entry);
        }
 private void WriteMeetingData(ExcelMeetingDataRequest obj)
 {
     logger.Debug("Write Meeting data");
     try
     {
         excelOperation.WriteMeeting(obj);
         eventAgg.GetEvent <PubSubEvent <ExcelMeetingDataResponse> >()
         .Publish(new ExcelMeetingDataResponse
         {
             ProcessCompletedSuccessfully = true
         });
     }
     catch (Exception)
     {
         eventAgg.GetEvent <PubSubEvent <ExcelMeetingDataResponse> >()
         .Publish(new ExcelMeetingDataResponse
         {
             ProcessCompletedSuccessfully = false
         });
     }
 }