IWbs.WbsWorkbookCalculationMode Property
Property WbsWorkbookCalculationMode() As WorkbookCalculationMode
This language is not supported or no code example is available.
Property Value
WorkbookCalculationModeThe calculation mode.
Some methods write directly to the WBS workbook, for example ITask.SetFieldValue. The workbook calculation is set to automatic by default. This is convenient but on the other hand, it will make any modifications to the workbook slower. This is not visible if you change only few cells. But the effect is very significant if many fields are modified this way.
To significantly improve performance when the ITask.SetFieldValue is called in a loop, it is recommended
to temporarily turn off the automatic calculation. After all modifications are finished, you should restore the calculation mode
to the original value and re-calculate the workbook explicitly by calling CalculateWbsWorkbook method.
It is very important that you restore the original calculation mode! The best way is to use Try
... Finally block
.
The following example illustrates how to use WbsWorkbookCalculationMode when changing the Quantity field of all minute tasks.
Dim wbs As IWbs = Es.CurrentVersion.Wbs Dim tasks As List(Of ITask) = wbs.GetTasksForScope("", False) Dim originalCalcMode As WorkbookCalculationMode = wbs.WbsWorkbookCalculationMode Try wbs.WbsWorkbookCalculationMode = WorkbookCalculationMode.Manual For Each task As ITask In tasks task.SetFieldValue("WBS_Quantity", 55) Next Finally wbs.WbsWorkbookCalculationMode = originalCalcMode If originalCalcMode = WorkbookCalculationMode.Automatic wbs.CalculateWbsWorkbook() End If End Try
This language is not supported or no code example is available.
IWbs wbs = es.CurrentVersion.Wbs; List<ITask> tasks = wbs.GetTasksForScope("", false); WorkbookCalculationMode originalCalcMode = wbs.WbsWorkbookCalculationMode; try { wbs.WbsWorkbookCalculationMode = WorkbookCalculationMode.Manual; foreach (ITask task in tasks) { task.SetFieldValue("WBS_Quantity", 55); } } finally { wbs.WbsWorkbookCalculationMode = originalCalcMode; if (originalCalcMode == WorkbookCalculationMode.Automatic) { wbs.CalculateWbsWorkbook(); } }
This language is not supported or no code example is available.