Reading in string values from an excel sheet

Reading in string values from an excel sheet

Anonymous
Not applicable
653 Views
6 Replies
Message 1 of 7

Reading in string values from an excel sheet

Anonymous
Not applicable

Hello,

I am trying to read in a value with its units in from excel and its giving me an error since I have a string value in the cell.

For example I'd like to read in like "60 in" from a cell.

 

Does anyone know if this is possible?

 

Thanks,

Matt

0 Likes
654 Views
6 Replies
Replies (6)
Message 2 of 7

johnsonshiue
Community Manager
Community Manager

Hi! Could you elaborate the workflow a bit. Is it iLogic/VBA? Or, you are linking an Excel spreadsheet to a part?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 7

S_May
Mentor
Mentor

@Anonymous,

 

here you can practice a bit (inventor & Excel)

 

2018-08-10 07_33_36-Excel Modelle.png

 

2018-08-10 07_30_38-Curves Samples.png

0 Likes
Message 4 of 7

Anonymous
Not applicable

This is in iLogic and I'm reading in numerical values by using this syntax:

Variable = GoExcel.CellValue("ExcelFileDirectory", "ExcelSheet", "Cell")     

 Although I'd like the option for the user to be able to enter units at the end of the numerical value as well, but when I try entering something like "60 in" into a cell if gives an error.

I was just wondering if there was a way to have iLogic read in a value with a string attached.

 

Sorry if I didn't give enough info hope this helps.

Thanks in advance!

-Matt

0 Likes
Message 5 of 7

johnsonshiue
Community Manager
Community Manager

Hi! If I understood how iLogic and VBA work correctly, the "variable" will need to be string type as opposed to numerical type.  You can make the variable a string variable or a text parameter. After reading it in, you can use other functions to convert the string value to a numerical value.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 6 of 7

Anonymous
Not applicable

I'm aware that you can bring it in, but I'm having an error doing so. Do you possibly know the syntax or function to convert from a string to double because I can't seem to find anything that works.

0 Likes
Message 7 of 7

johnsonshiue
Community Manager
Community Manager

Hi! In iLogic, you can use Val(String) function to extract the numerical value from the string.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes