ExcelRange in a function

Hi All,

Just wondering if someone could help me out with a function where I need to include an ExcelRange so I can loop through different sheets to grab out relevant data.

For example just taking the ExcelRange part, if I wrote a function like this:

function ()

{

ExcelRange MyExcelData = new ExcelRange().ReadValue("workbook.xlsx","sheet","A1:A5");

return MyExcelData;

}

(with the correct workbook and sheet etc)

It returns I have an issue with the part new ExcelRange()....

any tips on what I have done wrong?

Thanks

Wayne

Parents
  • HI  Wayne,

    a couple of suggestions 

    1. just as a low-level suggestion would it be possible to create an excel range for each sheet, then use a "list" of these ranges as inputs to your function? then write the function.

    2. as a part of the function could you use a series of excel read functions to build an array of data and then execute your function on that array

    Regards

    Brenden

    Brenden Roche

    Applications Engineer

    Bentley Systems, Manchester UK


    This is a test

  • Hi Brenden,

    I agree with option 1, it will work and I have used it in the past. For this one I have 52 sheets so I was looking for a way to loop through them. They are just floor levels of a building so I have a list of floors so could use that list to loop and match the names of the sheets. 

    The second one is where I am stuck. 
    I placed a ExcellRange with a read option in a function but it keeps giving me an error. Not sure I have the syntax correct? 

    Thanks

    Wayne

Reply
  • Hi Brenden,

    I agree with option 1, it will work and I have used it in the past. For this one I have 52 sheets so I was looking for a way to loop through them. They are just floor levels of a building so I have a list of floors so could use that list to loop and match the names of the sheets. 

    The second one is where I am stuck. 
    I placed a ExcellRange with a read option in a function but it keeps giving me an error. Not sure I have the syntax correct? 

    Thanks

    Wayne

Children
No Data