Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get Current Row So We Know Where To Start From.
- int currentRow = excelWorksheet.Dimension.End.Row;
- string campaignDate = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Select(x => x["CAMPAIGN_DATE"].Value));
- // Start The Real Work.
- foreach (var row in sourceExcelPackage.Worksheet(EVENT_1_WORKSHEET))
- {
- // CustomerID
- string customerId = row["CustomerId"].Value.ToString();
- // Create Report Object To Help Keep Things Readable.
- ReportObject reportObject = new ReportObject
- {
- EventType = row["EventType"].Value.ToString(),
- DateCreated = row["DateCreated"].Value.ToString(),
- EmailType = row["Context"].Value.ToString(),
- LinkClicked = row["Destination"].Value.ToString(),
- CampaignDate = campaignDate,
- SupporterID = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Where(x => x["DSM_CustomerID"] == customerId)
- .Select(x => x["SUPPORTER_ID"].Value)),
- PathwayStageHistoryOID = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Where(x => x["DSM_CustomerID"] == customerId)
- .Select(x => x["PATHWAY_STAGE_HISTORY_OID"].Value))
- };
- // Add Next Row.
- currentRow++;
- // Assign Data Here.
- excelWorksheet.Cells[currentRow, 1].Value = reportObject.SupporterID;
- excelWorksheet.Cells[currentRow, 2].Value = reportObject.CampaignDate;
- excelWorksheet.Cells[currentRow, 3].Value = reportObject.EmailType;
- excelWorksheet.Cells[currentRow, 4].Value = reportObject.DateCreated;
- excelWorksheet.Cells[currentRow, 5].Value = reportObject.EventType;
- excelWorksheet.Cells[currentRow, 6].Value = reportObject.LinkClicked;
- excelWorksheet.Cells[currentRow, 7].Value = reportObject.PathwayStageHistoryOID;
- // Return the current row as we may
- // use this to build some sort of progress.
- yield return currentRow;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement