Hi,
Is there a way to export and UltraGanttView to Excel?
-Anish
If you mean by calling one method off the control, then no. Iterating the Tasks collection and using our Excel exporter to get them into a worksheet should be a fairly simple matter though.
Hi, Could you pls guide me to a sample code? Have never used it before.
Ok, finally I was able to get it working. Just posting the code ... may help someone else.
private void btnExpGanttView_Click(object sender, EventArgs e){Infragistics.Excel.Workbook wb = new Infragistics.Excel.Workbook();
Infragistics.Excel.
Worksheet worksheet = wb.Worksheets.Add(Project.Name);// Create column headers for each column worksheet.Rows[0].Cells[0].Value = "Task Name";worksheet.Rows[0].Cells[1].Value = "Duration (Days)";worksheet.Rows[0].Cells[2].Value = "Start";worksheet.Rows[0].Cells[3].Value = "Finish";worksheet.Rows[0].Cells[4].Value = "Predecessors";worksheet.Rows[0].Cells[5].Value = "Resource Names";worksheet.Rows[0].Cells[6].Value = "Milestone";worksheet.Rows[0].Cells[7].Value = "% Complete";
//IterateTaskForExcelExportrowIndex = 1;
IterateTaskForExcelExport((Infragistics.Win.UltraWinSchedule.
TasksCollection)(calInfoPM.Tasks), worksheet);
wb.Save(
"C:\\Data.xls"); }
private void IterateTaskForExcelExport(Infragistics.Win.UltraWinSchedule.TasksCollection tasks, Infragistics.Excel.Worksheet workSheet){foreach (Infragistics.Win.UltraWinSchedule.Task task in tasks){// Starting at row index 1, copy all data rows in// the data table to the worksheet
WorksheetRow row = workSheet.Rows[rowIndex++];row.Cells[0].Value = task.Name;row.Cells[1].Value = task.Duration.Days;row.Cells[2].Value = task.StartDateTime.ToString();row.Cells[3].Value = task.EndDateTime.ToString();row.Cells[4].Value = task.Dependencies.ToString();row.Cells[5].Value = (task.Resources.Count > 0) ? task.Resources.All[0].ToString() : "";row.Cells[6].Value = (task.Milestone == true) ? "Yes" : "No";row.Cells[7].Value = task.PercentComplete.ToString();
// Call recursively on child tasksif(task.Tasks.Count > 0)this.IterateTaskForExcelExport(task.Tasks, workSheet);}}
Hi Brian, Can you pls tell me how to do it. I am kind of struggling here. Any thing that would give me a kickstart would be much appreciated.