XlsIO & Calculate using 4.2.0.37

What follows encapsulates what I want to do with a combination of XlsIO & Calculate. Needless to say it doesn''t work. Please can you review the code below and provide me with a working sample that does what I''m trying to do? Posted here because DirectTrac seems to be broken... Rgds Andy public void A002_Test_Calc_Simple001() { ExcelEngine xlEngine = new ExcelEngine(); IApplication iApp = xlEngine.Excel; xlEngine.ThrowNotSavedOnDestroy = false; IWorkbook iWB; iWB = iApp.Workbooks.Open(sshtFolder+"simple001.xls"); IWorksheet iWS = iWB.Worksheets["Main"]; // assign new values to input range iWS.Range["Input"].Value2 = new double[] {1,2,3,4,5,6,7,8}; // assign worksheet to calcsheet... myCalcSheet[] sheets = new myCalcSheet[1]; sheets[0] = new myCalcSheet(iWS); sheets[0].Name = iWB.Worksheets[i].Name; Hashtable ranges = new Hashtable(); foreach(IName name in iWS.Names) { ranges.Add(name.Name.ToUpper(), name.Value.Replace("''", "")); } CalcWorkbook cWB = new CalcWorkbook(sheets, ranges); cWB.Engine.LockDependencies = false; cWB.CalculateAll(); cWB.Engine.LockDependencies = true; // get the result double res = iWS.Range["Output"].Value2; // do it again.... iWS.Range["Input"].Value2 = new double[] {11,12,13,14,15,16,17,18}; cWB.Engine.LockDependencies = false; cWB.CalculateAll(); cWB.Engine.LockDependencies = true; // get the result res = iWS.Range["Output"].Value2; } public class myCalcSheet : CalcSheet { IWorksheet ssht; public myCalcSheet(IWorksheet sheet) { ssht = sheet; } }

1 Reply

AD Administrator Syncfusion Team July 19, 2006 12:24 AM UTC

XlsIO does not currently support directly assigning arrays to ranges. However, it does support importing arrays by specifying first row and first column. Here is a code snippet: int[] arrTest = new int[] { 1, 2, 3, 4, 5 }; //Importing the array to sheet at the specified location. sheet.ImportArray( arrTest,int firstRow,int

Loader.
Up arrow icon