Hey, I am trying to use parallel library to update cells content for a open IWorkbook, I use one thread for each IWorksheet inside the book, but always got error for index out of range issue which must be relative to the thread safe stuff. So I am wondering if multhreading support from syncfusion or not, if yes, can I get some sample code, my code piece like below:
//iBook opened from byte array already
ExcelTemplateContainer excelTemplateContainer = ExcelDB.GetExcelTemplateContainerFromDatabase(defaultDBParamList, exTemplateID, isForClientDownload);
var n = iBook.Worksheets.Count - 1;
var options = new ParallelOptions() { MaxDegreeOfParallelism = 12 };
Parallel.For(0, n, options, i =>
{
IWorksheet xlWorkSheet = iBook.Worksheets[i];
List xCellList = excelTemplateContainer.SheetCellsDictionary[xlWorkSheet.Name].ToList();
UpldateExcelsheetCellContent(xlWorkSheet, xCellList);
});
...........
//the update method here
public static void UpldateExcelsheetCellContent(IWorksheet xlWorkSheet, List xCellList)
{
foreach (ExcelCell xlcell in xCellList)
{
IRange xlWorkBookCell = xlWorkSheet.Range[xlcell.CellNumber];
if ((xlcell.AccountID ?? 0) != 0 || !xlWorkBookCell.HasFormula)
xlWorkBookCell.Value = xlcell.Text;
}
}
Regards,
hope can get some information soon.